Okay - I was expecting to find a lot of documentation on this problem but oddly enough I seem to be coming up pretty blank...
I am creating a SERVER / CLIENT network game - in this game the client will send a UDP "HELLO|XXX.XXX.XXX.XXX" message to the SERVER - the server will respond to the client with a "HEY|XXX.XXX.XXX.XXX". Then both client and server will form TCP connections using these IP-Addresses.
Now this works fine in my LAN (of course) but when I try to play online it doesnt work for one obvious reason, the IP-Address sent back-and-forth is the LAN IP and since I have a router it is not my REAL internet ip-address...
I use the following code to determine my CLIENT & SERVER ip-addresses...
This code returns stuff like "192.168.0.1", "192.168.0.2", etc.. (which is perfect for my LAN gaming)....
Is there maybe a way to get the IP-Address from the incoming UDP packet instead of explicitly sending it?
I use the following code to receive, I think in java (way-back-when) there was a way to get the ip-address of the person who sent the data from the socket? (could be wrong)
Or a way to maybe loop to my router somehow to get my actual WAN (internet) ip-address?
How do people usually solve this problem? I assume it is encountered fairly often in the real world....
Any ideas, hints, and help would be greatly appreciated, thanks
I am creating a SERVER / CLIENT network game - in this game the client will send a UDP "HELLO|XXX.XXX.XXX.XXX" message to the SERVER - the server will respond to the client with a "HEY|XXX.XXX.XXX.XXX". Then both client and server will form TCP connections using these IP-Addresses.
Now this works fine in my LAN (of course) but when I try to play online it doesnt work for one obvious reason, the IP-Address sent back-and-forth is the LAN IP and since I have a router it is not my REAL internet ip-address...
I use the following code to determine my CLIENT & SERVER ip-addresses...
Code:
IPAddress ipServer = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];
Is there maybe a way to get the IP-Address from the incoming UDP packet instead of explicitly sending it?
I use the following code to receive, I think in java (way-back-when) there was a way to get the ip-address of the person who sent the data from the socket? (could be wrong)
Code:
int nReceived = sktServer.ReceiveFrom(buffer, ref epSender);
Or a way to maybe loop to my router somehow to get my actual WAN (internet) ip-address?
How do people usually solve this problem? I assume it is encountered fairly often in the real world....
Any ideas, hints, and help would be greatly appreciated, thanks