This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: IP ADDRESS OF MACHINE
- From: Michal Lipták <liptak at isdd dot sk>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 28 Feb 2002 13:04:18 +0100
- Subject: RE: IP ADDRESS OF MACHINE
I would connect to some internet IP address and use getsockname() on the
connected socket..
int socket;
sockaddr local_addr;
socklen_t namelen=sizeof(local_addr);
getsockname(socket,&local_addr,&namelen);
printf("My IP is %s",inet_ntoa(local_addr.sin_addr));
m.
> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
> Behalf Of snodx@hotmail.com
> Sent: Thursday, February 28, 2002 1:02 PM
> To: gcc-help@gcc.gnu.org
> Subject: Re: IP ADDRESS OF MACHINE
>
>
> Alright Mr Green, that was a nice point. Your post has made me
> refine my question a bit more.
>
> Maybe there are several interfaces installed on a system. BUT the
> interface
> through which an internet browser like Netscape Navigator or Lynx
> interacts with
> the Internet HAS to be after all one. I am talking about THIS IP
> Address that the
> system is using to talk to the internet. How does the internet
> browser access the
> Internet? I want a C/C++ program to detect THIS interface and
> display IT'S IP Address.
>
> That leads to the second part of your question is there a better
> place where this
> question can be posted. I think the best place would be where
> network issues are
> discussed. I shall indeed do so. I posted this question here because
>
> So now how do I obtain the TCP/IP Address of that interface
> through which an internet
> browser interacts?
>
> Thanks for the input anyway.
>
> SNODX
>