How can i get IP address of my local machine.

How can i get IP address of my local machine.

Post by Ofir » Thu, 30 Aug 2001 00:23:23



Hi,
I try to fined function how get the IP address of my local machine, but
nothing found.
Which function I need to use for getting my IP address of my local machine.

thank you in advanced.

 
 
 

How can i get IP address of my local machine.

Post by CheckAbdou » Wed, 29 Aug 2001 23:26:09


See if this helps..

        http://cui.unige.ch/OSG/people/Past/fuentes/Mfc/HowTo_48.html

Cheers
Check Abdoul
-----------------


Quote:> Hi,
> I try to fined function how get the IP address of my local machine, but
> nothing found.
> Which function I need to use for getting my IP address of my local
machine.

> thank you in advanced.


 
 
 

How can i get IP address of my local machine.

Post by Ignacio Nicolás Rodrígue » Wed, 29 Aug 2001 23:30:00


gethostname() then gethostbyname().
 
 
 

How can i get IP address of my local machine.

Post by TiTi » Thu, 30 Aug 2001 21:50:00



Quote:> Hi,
> I try to fined function how get the IP address of my local machine, but
> nothing found.
> Which function I need to use for getting my IP address of my local

machine.

// Retrieve IP adres.
char szBuffer[256];
CString ipadres(_T("0.0.0.0"));

WSADATA WSAData;
WORD wVersionRequested = MAKEWORD( 2, 0 );

if(WSAStartup(wVersionRequested, &WSAData) == 0)
{
  if(gethostname(szBuffer, sizeof(szBuffer)) == 0)
  {
   HOSTENT* h=gethostbyname(szBuffer);
   ipadres = inet_ntoa(*(IN_ADDR*) h->h_addr);
  }

  WSACleanup();

Quote:}

Hope this helps

TiTi

 
 
 

How can i get IP address of my local machine.

Post by Ofir » Fri, 31 Aug 2001 21:52:38


TiTi thanks a lot for your helping me.




> > Hi,
> > I try to fined function how get the IP address of my local machine, but
> > nothing found.
> > Which function I need to use for getting my IP address of my local
> machine.

> // Retrieve IP adres.
> char szBuffer[256];
> CString ipadres(_T("0.0.0.0"));

> WSADATA WSAData;
> WORD wVersionRequested = MAKEWORD( 2, 0 );

> if(WSAStartup(wVersionRequested, &WSAData) == 0)
> {
>   if(gethostname(szBuffer, sizeof(szBuffer)) == 0)
>   {
>    HOSTENT* h=gethostbyname(szBuffer);
>    ipadres = inet_ntoa(*(IN_ADDR*) h->h_addr);
>   }

>   WSACleanup();
> }

> Hope this helps

> TiTi