  | |  | Getting UDP through NAT/firewalls/whatever for a game. | Getting UDP through NAT/firewalls/whatever for a game. 2004-01-07 - By MacFirst
Back In the game I'm writing, the client opens a TCP socket to the server, the server sends (TCP) a "send me a UDP packet with this magic number, so I know it's you", then the client sends "here's a UDP packet with your magic number" packet.
...Which seems like a screwy dance, but all the Google info I can find tells me that's really the only "official" way for a server to find out a client's UDP port to receive stuff.
So far, so good: the server can now identify UDP packets coming from user X.
My problem is that, from behind certain NAT routers, firewalls and whatnot, the client cannot RECEIVE UDP packets from the server. Btw, this works in a lot of places (my house, friends' offices, various open-airpot coffee shops), but not in a lot of others (i.e., another friend's house, another open-airpot at the mall, everywhere on the Apple campus), so I'm assuming it's something to do with the weird IP-masquerade/NAT thingamabob.
(I just started learning network innards recently, so forgive me if I misuse some of the technical terms ;)
So my question is: what do I need to do so that my server can know what port to send UDP packets *TO*, so that the client can receive them under a wider variety of circumstances?
Thanks!
(NOTE: MS spelling dictionary recognizes "thingamabob" as a word!)
--- Someone else helped a little by posting... ---
> In article <Misc-3A0BE2.09155007012004@(protected)>, > Miss Elaine Eos <Misc@*your-shoes*PlayNaked.com> wrote: > >So my question is: what do I need to do so that my server can know what > >port to send UDP packets *TO*, so that the client can receive them under > >a wider variety of circumstances?
> If the client initiates the connection, try having the server send > them right back to (its version of) the client's address. This'll > require the client to send/receive on the same port, but that > shouldn't be much of a problem.
It turns out that this is what works "most of the time", "under normal circumstances." But it doesn't seem to work the rest of the time -- that is, for 50% of my potential players.
50% is too high for me, so I'm trying to fix it.
Various routers change the port number along the way, so it's not a simple matter of setting it to some number. I don't think. Maybe there's a trick to it that I'm not getting -- but that's what the question is all about. __ ____ ____ ____ ____ ____ ____ ____ ____ ____ mac-games-dev mailing list | mac-games-dev@(protected) Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac -games-dev Do not post admin requests to the list. They will be ignored.
Earn $52 per hosting referral at Lunarpages.
|
|
 |