Qt-interest Archive, July 2003
Platform independent network interface identification
Message 1 in thread
I didn't see anything in the docs and doubt it exists but I thought I'd
ask anyway :-)
Is there a platform independent way available in Qt to discern the IP
addresses of the underlying system's network interfaces? My application
needs to respond differently if it is being run on the same computer as
its database than if it is connecting to a remote database. I'd like to
be able to tell if the user has entered in their own ip address (other
than localhost or 127.0.0.1) as the destination address for the database
connection. I don't see a good way to do that in a way that is portable
across *NIX, Windows and now Mac. Thanks - John
--
[ signature omitted ]
Message 2 in thread
Hi,
> I didn't see anything in the docs and doubt it exists but I thought I'd
> ask anyway :-)
> Is there a platform independent way available in Qt to discern the IP
> addresses of the underlying system's network interfaces? My application
> needs to respond differently if it is being run on the same computer as
> its database than if it is connecting to a remote database. I'd like to
> be able to tell if the user has entered in their own ip address (other
> than localhost or 127.0.0.1) as the destination address for the database
> connection. I don't see a good way to do that in a way that is portable
> across *NIX, Windows and now Mac. Thanks - John
I don't think there's a portable (read POSIX) way to do that in UNIX,
and certainly not in Qt. Actually I seem to recall one needs
undocumented ioctl() calls on Solaris for example (run ifconfig under
truss). Some people end up calling something like:
system("/sbin/ifconfig -a")
to avoid messing with undocumented, unstable APIs.
--
[ signature omitted ]
Message 3 in thread
Thanks. That's what I was afraid I'd have to do (and hope that the
system executables are always in the same directory!). I suppose
nothing a few #ifdef's can't fix :-( - John
On Mon, 2003-07-14 at 14:16, Dimitri wrote:
> Hi,
>
> > I didn't see anything in the docs and doubt it exists but I thought I'd
> > ask anyway :-)
> > Is there a platform independent way available in Qt to discern the IP
> > addresses of the underlying system's network interfaces? My application
> > needs to respond differently if it is being run on the same computer as
> > its database than if it is connecting to a remote database. I'd like to
> > be able to tell if the user has entered in their own ip address (other
> > than localhost or 127.0.0.1) as the destination address for the database
> > connection. I don't see a good way to do that in a way that is portable
> > across *NIX, Windows and now Mac. Thanks - John
>
> I don't think there's a portable (read POSIX) way to do that in UNIX,
> and certainly not in Qt. Actually I seem to recall one needs
> undocumented ioctl() calls on Solaris for example (run ifconfig under
> truss). Some people end up calling something like:
> system("/sbin/ifconfig -a")
> to avoid messing with undocumented, unstable APIs.
>
> --
> Dimitri
>
> --
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]