Reputation: 305
Trying to develop a reliable UDP protocol for my game (made in GameMaker: Studio) that connects to a Java server. I need to ensure packets arrive and that they arrive in the correct order.
I'm trying to model off of the TCP protocol to do this, and one thing that's confusing me is the 3-way handshake: when does it occur?
Is the handshake basically when you first connect to something? It's only ever done once? (until the connection is dropped)
If that's the case, then what data am I attaching to regular packets?
Say I have my initial 3 packets for the connection: SYN -> SYN-ACK -> ACK
Let's assume this all went smoothly, boom we're connected.
And then let's say I want to send the server a message: "Hello". Am I basically doing SYN -> SYN-ACK -> ACK
for this message? What exactly am I attaching to this message packet/datagram to ensure it arrives and arrives in order?
Upvotes: 1
Views: 349
Reputation: 344
And then let's say I want to send the server a message: "Hello". Am I basically doing SYN -> SYN-ACK -> ACK for this message?
No. The packet is transmitted with no warranty.
What exactly am I attaching to this message packet/datagram to ensure it arrives and arrives in order?
You can add a sequential number in your packet and reorder them programmatically: if you receive packets 1,2,3 and than 5 you must wait for packet 4.
I need to ensure packets arrive and that they arrive in the correct order.
If you need both Re-transmission and ordered arrival (and probably avoid duplication), it is very difficult to do programmatically something better then TCP!
Upvotes: 2