Hello people,
I'm making simple client server program. I have done this before.
I have two computers in home LAN and want to test it.
Computer A on which server program is located has 192.168.0.2 IP address
Computer B on which is client program has IP: 192.168.0.1.
Aplication is simple and basically it just send/receive strings.
Everything works OK if I on client side do something like this:
But this solution require me to know server address in advance and to hard coded it.Code:he = gethostbyname ("192.168.0.2"); server_adresa.sin_family = AF_INET; server_adresa.sin_port = htons (PORT_NUM); server_adresa.sin_addr = *( (struct in_addr * ) he->h_addr );
Is there any way, and API function (Windows) which can help me to do this dinamically.
I know that is hard.
Basically I want this:
On Computer A I want to open port and listen, and on computer B when I start client program to try to connect to server over home LAN.
I don't think there is a simple way to do this, but just want your advice.
Thanks