LOCAL IP ADDRESS (MY IP ADDRESS)

LOCAL IP ADDRESS (MY IP ADDRESS)

Post by J. J. VerScha » Wed, 19 Mar 1997 04:00:00



I am writing some sockets code in C++.
I am curious how I can if there is a funtion or environment variable
that I can use to locate the IP address of the local machine I am
working on.  I need to do this for some server stuff.  Any help
would be appreciated especially an example.  Thanks

-jean

--

===============================================
  Jean J. VerSchave                        
  Student, University of Illinois                  
  Electrical Engineering/Computer Science  

===============================================

 
 
 

LOCAL IP ADDRESS (MY IP ADDRESS)

Post by Chris Marriot » Wed, 19 Mar 1997 04:00:00




Quote:>I am writing some sockets code in C++.
>I am curious how I can if there is a funtion or environment variable
>that I can use to locate the IP address of the local machine I am
>working on.  I need to do this for some server stuff.  Any help
>would be appreciated especially an example.  Thanks

Jean,

I don't mean to be rude, but it might be a good idea to read up on using
standard Berkeley socket functions; it sounds as though you don't really
understand how to use the functions at the moment! There are several
good books around which describe socket programming; Ralph Davis's
"Windows NT Network Programming" is excellent.

The standard way to retrieve the list of local IP addresses (there can
be more than one) is to first call "gethostname" to find the "network
name" of the local machine, and then call "gethostbyname" to get the IP
address list.

Chris

----------------------------------------------------------------

Creators of fine astronomy software for Windows.
For full details, visit our web site at http://www.skymap.com

 
 
 

LOCAL IP ADDRESS (MY IP ADDRESS)

Post by Rob Woern » Fri, 21 Mar 1997 04:00:00



Quote:>I am writing some sockets code in C++.
>I am curious how I can if there is a funtion or environment variable
>that I can use to locate the IP address of the local machine I am
>working on.  I need to do this for some server stuff.  Any help
>would be appreciated especially an example.  Thanks

>-jean

Use gethostname(), followed by gethostbyname()

Sorry, no code...

 
 
 

LOCAL IP ADDRESS (MY IP ADDRESS)

Post by J.J. Keijs » Sat, 22 Mar 1997 04:00:00




Quote:>I am writing some sockets code in C++.
>I am curious how I can if there is a funtion or environment variable
>that I can use to locate the IP address of the local machine I am
>working on.  I need to do this for some server stuff.  Any help
>would be appreciated especially an example.  Thanks

I assume you're programming using a WINSOCK library. there's a call in the
winsock API to get the curreny host name and IP address. For a sample,
download ftp://ftp.winsite.com/pub/pc/win3/winsock/ws_ping.zip, a winsock
ping program which comes with sources.

HTH,

JJ

----------------------------------------------------------
                 *NOTE*
   My Email return address is not correct
    in order to avoid mass mailings...
     These are the correct addresses:

  Jan Just (JJ) Keijser

  X400: C=NL A=400NET P=SHELL O=SIEP RIJSWIJK
        OU1=EPT-RO OU2=OPENMAIL S=KEIJSER I=JJ
          or

  X400: C=GB A=ATTMAIL P=Logica O=LBV OU1=LBVRTDA S=KEIJSERJJ

  (who said X400 addresses aren't easy to remember :-)

  Where do you want to crash today?
  My views are my own...
                    flames > /dev/null 2>&1
----------------------------------------------------------

 
 
 

LOCAL IP ADDRESS (MY IP ADDRESS)

Post by Giampaolo Tomasson » Sun, 23 Mar 1997 04:00:00




Quote:>   Where do you want to crash today?

Ahahah! ;-)

VERY funny! Do you mind if I steal your idea?

--

------------------------------------------------------
Giampaolo Tomassoni     Information Systems Consultant
P.za 8 Aprile 1948, 4   Tel/Fax: +39 (578) 21100

ITALY

* Reply address junked to avoid spamming.
  Use the above address to send mail