Advertisement

Problem with IP address

Started by May 21, 2002 12:53 PM
2 comments, last by Gammastrahler 22 years, 8 months ago
hi, i have programmed a small server and client apps using WinSock. sicne i have no local network at home, the client currently uses my own PC´s IP number to connect to the server. but now i want to test with a buddy over the inet. the problem is, how can a client connect to the server without knowing the IP address of the server? the problem is that the IP address of our PC´s cange every time a new internet connection is made. commercial programs like ICQ can do this. i only have the port on which to communicate, which is 6000. how can i realize that ? any help would be appreciated , thanks! Gammastrahler [edited by - Gammastrahler on May 21, 2002 1:54:58 PM]
From MSDN:

gethostnameThe Windows Sockets gethostname function returns the standard host name for the local machine.int gethostname(  char FAR *name,    int namelen       );Parametersname [out] Pointer to a buffer that receives the local host name. namelen [in] Length of the buffer.  
daerid@gmail.com
Advertisement
Yes, the code above will tell you your IP address. But I don''t think that totally answers the question.

The simple fact is you can''t connect peer to peer without it''s current IP address.

Commercial programs like ICQ use a client/server architecture. They give you a unique identifier UIN that is associated with you. When you sign on, you register with their central server that sets the current IP address associated with that UPN and retrieves the current IP''s of any one in your contact list.
dyndns.org

You can set up Dynamic DNS registration with that site, then you just need to use a gethostbyname() with whatever DNS name you register. There is also an update client you''ll have to run on your machine that monitors IP address changes and updates your DNS entry.

This topic is closed to new replies.

Advertisement