starboarder2001 at July 14th, 2003 23:25 — #1
in c++ what function will return your IP address? I have searched for it but no luck. I figured you guys would know it off the top of your heads.
dk2 at July 14th, 2003 23:53 — #2
If you're using windows, you can get your IP address using WinSock. You can't get the IP address in "C/C++". You'll have to use a library.
wVersionRequested = MAKEWORD( 2, 0 );
if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
if( gethostname ( name, sizeof(name)) == 0)
if((hostinfo = gethostbyname(name)) != NULL)
ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
don't forget to link with Wsock32.lib
ma_mestre at July 15th, 2003 04:10 — #3
if u use apex's code ( into VC6.0 ), and u need #include \ u must put #include \ before windows include. Otherwise the compiler found data types repeated.
starboarder2001 at July 19th, 2003 02:12 — #4
I have another question....
I am using WinSock.
When i call: recv() it waits at that line until it is sent something. Is there a way i can set the function to time out if nothing is sent after a few secs? I am writing a simple chat program..and i need it to check if something was recieved..and if it didnt then just contenue with the program.
//recieve text //i dont need it to wait here until it is sent something :\
obunako at July 19th, 2003 05:47 — #5
Using WSAAsyncSelect u can recive a message to a window procedure when u get some data, or other network event, about u socket. Try to use it !!! :nod:
drunkencoder at July 21st, 2003 11:28 — #6
or have a look at select() ...