UDP connections across gateways
ok, I''ve built a client-server system for our game engine to send game messages using UDP. when a new player connects, the network engine automatically negotiates for free UDP ports on both client and server using a TCP control connection.
Now that works fantastic as long as the machines are in the same network. But I connect to the internet thru a gateway, and i''d still like to be able to connect to a server which is somewhere on the internet and not in my LAN. Sending stuff to a server works fine, but getting data from the server doesnt work, since the gateway doesnt know to whom to forward the packets. The packets are just fired to a special port without any further meaning for the gateway.
How do commercial games like quake solve this? is there a way to get around this problem or do they just fallback to TCP (ick)?
Never try to explicitely tell the server your IP info or you run into these kinds of problems. Instead the server needs to get the client IP using recvfrom and just use that.
I''m not sure why you are negotiating ports. The usual thing to do is to have a well-known server port - espcially since you must already have such a port to setup your initial TCP connection. The client port should be irrelevant.
I''m not sure why you are negotiating ports. The usual thing to do is to have a well-known server port - espcially since you must already have such a port to setup your initial TCP connection. The client port should be irrelevant.
-Mike
Does your client have single port for send and receive data or he sends and receives to/from the same port ?
Anon Mike: I''m negotiating ports, since I didnt want to have two well-known server ports. You think a UDP-only connection would suffice for a game? If so, I have to implement my own reliability stuff, nay?
Barabashka: each client has one UDP port to send/receive, same with each slot on the server
Barabashka: each client has one UDP port to send/receive, same with each slot on the server
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement