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?
In my experience, I used the UDP to send in broadcast a packet (just packet id to understand what i'm receiving) to get every servers created in the current network. Imagine 1 client called "A" looking for possible matches in the network. Other clients waiting for players are sending an UDP datagram in broadcast so everyone in that network know about them. After the client "A" connect to a match, the host is linking with "A" via TCP, to get a stable connection. To get the order of the packets, send an initial id digit, so when the client receive the packet know what he received ( ex. id=1 --> ping, id=2 --> player_position, id=3 --> hp_update ). You should get your way programmatically to get an order of the packets.