• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker TCP vs UDP?

P

ponotte

Guest
I have this game in developement that is going to be fps space shooting multiplayer, and i've been doing to networking after some tutorial, as i learnt networking at the same time, well, the tutorial was made with TCP and what i've understood, UDP would be better on game like i have. well, i've gone pretty far with the networking, so is it possible to change it from TCP to UDP on the fly? does it take much time to change it? or should i just do everything from beginning, wich i really dont want to do at this point.
 

FrostyCat

Redemption Seeker
TCP and UDP code are not interchangeable, as the former is connection-based and the latter is connectionless. If you hard-coded the networking calls into objects, here are the things you need to replace:
  • network_send_packet() to a socket by network_send_udp() to an IP address and port
  • network_connect() and network_destroy() with your own handshake
  • Remove all dependencies on connect- and disconnect-type Networking events
  • Account for potential out-of-order packets
The non-interchangeability of TCP and UDP, as well as the wide variety of multiplayer service vendors, have turned me off the hard-coded method commonly encouraged by tutorials. Delegating the messaging to scripts and interchangeable controller objects is now my preferred method.
 
P

ponotte

Guest
TCP and UDP code are not interchangeable, as the former is connection-based and the latter is connectionless. If you hard-coded the networking calls into objects, here are the things you need to replace:
  • network_send_packet() to a socket by network_send_udp() to an IP address and port
  • network_connect() and network_destroy() with your own handshake
  • Remove all dependencies on connect- and disconnect-type Networking events
  • Account for potential out-of-order packets
The non-interchangeability of TCP and UDP, as well as the wide variety of multiplayer service vendors, have turned me off the hard-coded method commonly encouraged by tutorials. Delegating the messaging to scripts and interchangeable controller objects is now my preferred method.
i've gone pretty far now on changing the code from tcp to udp, and i think im doing pretty good, as i got the connection working after a while of configuring. but i haven't used network_connect or network_destroy anywhere, are these something i should put somewhere? on client and server?
 

FrostyCat

Redemption Seeker
i've gone pretty far now on changing the code from tcp to udp, and i think im doing pretty good, as i got the connection working after a while of configuring. but i haven't used network_connect or network_destroy anywhere, are these something i should put somewhere? on client and server?
network_connect() is never used in UDP because UDP is a connectionless protocol. network_destroy() can and should still be used to clean up sockets when you no longer need them.
 
P

ponotte

Guest
network_connect() is never used in UDP because UDP is a connectionless protocol. network_destroy() can and should still be used to clean up sockets when you no longer need them.
Alright! I think i got the hang of it! it's cool that i have learnt networking nearly completely in month. Thanks for the answers!
 
Top