[fpc-pascal] lNet getting the local IP

2010-10-08 Thread Brian Winfrey
>> >> I didn't try it, but I see that it tries to connect to google's dns serve= >r, >> so it'd fail miserably if the computer has no internet access. >> >> Bye >> -- >> Luca >> > >I tested, without web access does not work. :o A hard coded address will of course fail if it cannot be reached. The c

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Boris Samorodov
On Thu, 7 Oct 2010 16:00:31 -0700 Brian Winfrey wrote: > Here are the modifications I made in exploring this issue: It works on: - % uname -a FreeBSD host.ipt.ru 9.0-CURRENT FreeBSD 9.0-CURRENT #3 r213198M: Mon Sep 27 15:43:54 MSD 2010 b...@host.ipt.ru:/usr/obj/usr/src/sys/HOST i386 ---

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Brian Winfrey
I don't know if you noticed, but it appears that code has some depracated properties that should be changed. Here are the modifications I made in exploring this issue: program GetPrimaryIpAddress; {$mode objfpc} uses baseunix, unixtype, sockets, SysUtils; procedure Get(out AddrOut: stri

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Brian Winfrey
t := ''; >> >>> {$IFDEF UNIX} >> >>>        VStrTemp := TStringList.Create; >> >>>        VProcess := TProcess.Create(nil); >> >>>        try >> >>>          VProcess.CommandLine := >> >>>            '

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread silvioprog
t; >>>try > >>> VProcess.CommandLine := > >>> 'sh -c "ifconfig eth0 | awk ''/inet end/ {print $3}''"'; > >> > >> Yuck. This doesn't work on my system (debian). If you really want

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Brian Winfrey
inet end/ {print $3}''"'; >> >> Yuck.  This doesn't work on my system (debian).  If you really want the >> least effort, you may have more luck with simply parsing `hostname -I` >> somehow.  The right way to do this is with an ioctl, I believe >>

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Frank Church
I am developing for an embedded system and found out that 'nmap --iflist' does a faily good job of this if the output is examined and parsed properly. If it is suitable and you can possibly extract the code (if you are prepared to go that far) it might help you. It is also cross platform On 7 Octo

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread silvioprog
2010/10/7 Luca Olivetti > > I didn't try it, but I see that it tries to connect to google's dns server, > so it'd fail miserably if the computer has no internet access. > > Bye > -- > Luca > I tested, without web access does not work. :o -- Silvio Clécio, *programmer* *ObjectPascal* __

[fpc-pascal] lNet getting the local IP

2010-10-07 Thread bwCode4U
Choose a different address that would not fail in a specific situation. For example, one could read their /etc/resolve file to get the dns server. Brian Winfrey ~~ Important Note: Code provide as an example. There could be errors or risks in using it. There is no warranty implied or imp

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread Luca Olivetti
En/na Marco van de Voort ha escrit: In our previous episode, Brian Winfrey said: I found an example for linux on stack overflow that was in c http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-computer Compiles on FreeBSD and the result looks sane (but on a system

Re: [fpc-pascal] lNet getting the local IP

2010-10-07 Thread silvioprog
Wow, worked perfectely in Ubuntu-10.04, Mandriva-2010 and openSUSE-11.2. Thanks for the exelent solutions. :) 2010/10/7 Brian Winfrey > > I found an example for linux on stack overflow that was in c > > http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-computer > > -

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Marco van de Voort
In our previous episode, Brian Winfrey said: > I found an example for linux on stack overflow that was in c > http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-computer Compiles on FreeBSD and the result looks sane (but on a system that has a routable address) _

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Brian Winfrey
necessary permissions. That is >>> the main security risk and it is solved by this approach. The fact >>> that another process running under your login not using O_EXCL >>> could overwrite it is not an extra security risk (if you have a >>> rogue process running und

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Henry Vermaak
On 06/10/10 14:27, Felipe Monteiro de Carvalho wrote: Ok, thanks everyone, it seams that I managed to extract a function from Silvio's code which doesn't use Synapse. I only tested in Windows so far: unit chesstcputils; {$mode objfpc}{$H+} interface uses {$IFDEF MSWINDOWS} Winsock, {

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Marco van de Voort
In our previous episode, Felipe Monteiro de Carvalho said: > function ChessGetLocalIP(): string; > VProcess.CommandLine := > 'sh -c "ifconfig eth0 | awk ''/inet end/ {print $3}''"'; Fails if eth0 is not the primary NIC. Doesn't work on non-linux (that use other ethernet naming

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Andrew Brunner
On Wed, Oct 6, 2010 at 7:55 AM, Sven Barth wrote: > You'll only find "127.0.0.1" for my computer there... I don't think that > this is a very good solution. Oh well. That makes sense b/c these are servers that I have obtaining the same IP over DHCP. On clients when DHCP is being used with dynami

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Felipe Monteiro de Carvalho
Ok, thanks everyone, it seams that I managed to extract a function from Silvio's code which doesn't use Synapse. I only tested in Windows so far: unit chesstcputils; {$mode objfpc}{$H+} interface uses {$IFDEF MSWINDOWS} Winsock, {$ENDIF} Classes, SysUtils; function ChessGetLocalIP(): s

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Sven Barth
Am 06.10.2010 14:49, schrieb Andrew Brunner: I just read the first line in /etc/hosts file. The first entry is the IPv4. On Tue, Oct 5, 2010 at 3:04 PM, Felipe Monteiro de Carvalho wrote: hello, I am searching for a way to get the local IP. I already found examples with winsock, synapse and

Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Andrew Brunner
I just read the first line in /etc/hosts file. The first entry is the IPv4. On Tue, Oct 5, 2010 at 3:04 PM, Felipe Monteiro de Carvalho wrote: > hello, > > I am searching for a way to get the local IP. I already found examples > with winsock, synapse and indy. Does anyone know how to do that wit

Re: [fpc-pascal] lNet getting the local IP

2010-10-05 Thread Felipe Monteiro de Carvalho
Hello, Actually it uses both synapse (under unix) and winsock (under Windows). What should one put in the parameter AHTTPSend: THTTPSend ? Where is this type declared? thanks, -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists

Re: [fpc-pascal] lNet getting the local IP

2010-10-05 Thread silvioprog
Local IP without winsock, synapse, indy or lnet: http://code.google.com/p/lazsolutions/source/browse/trunk/Core/LSHTTPSend.pas#127 2010/10/5 Felipe Monteiro de Carvalho > hello, > > I am searching for a way to get the local IP. I already found examples > with winsock, synapse and indy. Does anyo

[fpc-pascal] lNet getting the local IP

2010-10-05 Thread Felipe Monteiro de Carvalho
hello, I am searching for a way to get the local IP. I already found examples with winsock, synapse and indy. Does anyone know how to do that with lNet? thanks, -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org