TCP, only for setup and initial sync... (Also for reconnect.)
Always use outgoing ports that are above 1024.
UDP, (Blind packets), for spewing out a time-stamped location and action-list. (More like a time-line script.)
Ignore PING, most routers/ISP will (Block, Drop, Ignore) even if listening for one.
Occasionally send an, "I am alive" packet.
Most TCP has a forced time-out, and will kill a, "Stay alive", even though it has not requested a "Close". (Less of a problem on a simple router/switch for local.
You have to have the program "Assume", that the remote player is doing the last thing he did, until corrected by an incoming packet. If he is running forward, he keeps running forward, but slightly slower, until the incoming packet says... Hey, I am at (XZY)@12:00:01... You have to transition mild changes, and bump harsh changes... The further the distance of correction, the more harsh the corrective action. (Movement is only a suggestion. No need to send EVERY frame, only 1/10 from the remote player. Packets should NEVER be assumed to arrive in order.) You still use intercepting collision on the remote player, so the auto-pilot movement does not carry the player through walls or other objects. The corrected location will have also been through the collision, on the remote players computer.
You only need one UDP port open. You can actually use a common allowable non-blocked port... like port 81. That is HTTPS, and is usually never blocked by most ISP, and packets are usually not scanned, since they are likely encrypted, and not containing a valid blocking header. (ISP's use a filter to detect incoming packet headers, and certain "Unknown" potential viral packets get randomly dropped. Plus, UDP has a lower priority to a network hub, than a TCP.)
TCP uses a HAND SHAKE, and has a special "Packet Ration", and "ReSend" function. It does this automatically. It is horrible for instant data, as all data is buffered until a certain packet size is reached, or a time-limit expires. When a packet is missing... it will request a resend of the missing packet, holding the remaining buffer data hostage until it gets it. (If it never gets it, the connection gets terminated due to an error.)
IPX/SPX is better for games, it is like UDP on steroids... but has data limitations. (Great for LAN.)
These are just some things I learned while playing with my own servers, and while setting up live connections. (Nine times out of ten, I could use the junky VB OCX for simple solid connections for hours and hours, without much problem.)
A browser will open up 1-10 ports for incoming objects. It does not depend on one stay-alive TCP, and will even open a UDP for some web elements like streaming data files. A nifty tool called TCPVIEW.
http://technet.microsoft.com/en-us/s.../bb897437.aspx
The creator has TONS of other neat tools. Great for a developing aide.
Bookmarks