GameMaker Servers GML

Neptune

Member
I'm trying to learn anything I can about networking and multiplayer.
If I wanted to create the most simple multiplayer game... each player is a square, and they can move around a box or something.

I've gathered I'd need a "server" and have it hosted somewhere.
Can I create a server in GML? What does that look like? Where would I host something like this?
Is a "server" something I have to create in a different programming language, and have async calls to it?

Anywhere I look where people ask similar questions, they get the "Too broad, you're dumb," reply.
Or the "There are 100 ways to do it, but they're all super slow and impossible," reply.

So I guess, I'm not looking for opinions, but rather information from someone currently doing it, or someone who has successfully created a multiplayer game in GMS2.

Thank-you!
 

lolslayer

Member
Haven't done it in GMS2 but quite certain that it's the same as GMS1.4

If you want to keep things simple, you can easily use a GameMaker project to set up a server. The server acts as the host of the match and sets up the communication between the players. When a player for example presses a key on the keyboard, you send a message to the server that you pressed the key, and then the server sents a message to the other players that the first player pressed a key.

A server also handles the game just like all the other players (so the movement for example gets calculated as well on the server), and every now and then it sends the current data that needs to be synced to all the players, then the players can check if their data is correct, and if not, correct it by overwriting their data with the server's data.

Hosting can be done anywhere, your own PC is just fine, just make sure that you can connect with other people by using port-forwarding or hamachi
 

Surgeon_

Symbian Curator
The simplest way to do it is to have one of the players also act as the authoritative server - his instance of the game would collect inputs from all players (including himself), update the game state and then send packets describing this updated state to all clients, who would basically just have dummy objects move on their screen.

Creating slow-paced games is quite easy this way, and you can use TCP to send updates every 10 steps or so.
Now, if you want a fast-paced game, then the only way to go is UDP (because it doesn't have congestion control like TCP does, so you can send updates every step without delays), but UDP can also drop packets which can cause issues and there are 2 ways to fix this:
1) Use a hybrid TCP-UDP architecture - use TCP to send crucial updates that you absolutely need to arrive, like chat messages, player deaths and so on, and use UDP to send information that can occasionally get lost without causing much trouble, for example instance coordinates (doesn't matter if you lose the packet saying player1.y = 49 if there's another one saying player1.y = 50). However, this is a bandaid fix: Do it only if you lack the willpower, time or skill to use option number two.
2) Create a custom protocol on top of UDP which would track sent and received packets, send acknowledges, retransmit lost packets etc. - everything that TCP does in the background. Why not just use TCP then, you ask? TCP has a very heavy-handed approach to handling things, favouring reliability and ordering over speed, but also does not expose the way it works in any way, so if you don't like it (and you won't), then tough luck. In contrast, UDP is very bare-bones, but with a custom protocol made by yourself, you can fine tune it according to your game. However, this is hard to do properly and you can easily make a mess and end up with disadvantages of both TCP and UDP and advantages of none. I think there are some libraries to help with this.

Another issue with fast-paced games is lag. Until we get to Star Trek levels of technology, there's no way to avoid it, so you can only hide it. This is a broad and difficult topic, but you can find good information here: https://gafferongames.com/tags/networking
 

The-any-Key

Member
I'm trying to learn anything I can about networking and multiplayer.
If I wanted to create the most simple multiplayer game... each player is a square, and they can move around a box or something.
If you want to start simple. You can use extensions. There are several on the marketplace. You can also use one I currently is the keeper of: https://the-any-key.itch.io/gmnet-base-template

I got several videos that explain how to use it. Note that this is in gns1.4. But you can import it and use it in gms2.
 

Neptune

Member
Thanks for replies!
Simple is good, id like to view and understand the GMnet code, and also GM Punch looks like the piece that deals with servers.

Im less interested in actually using it to make anything, but im very interested in being able to create my own "GMnet".
 

Neptune

Member
Sorry i skipped over some replies on accident, thank-you for the info!

@Surgeon_ So it sounds like UDP is where i should start, and then I can establish some techniques to make it more reliable? Kinda like making youre code efficient after the robust systems are done...

@lolslayer So you mentioned hamachi and port forwarding, is it not possible to circumvent any of this, allowing players to play with others at ease? My own friends groan and moan at the mere mention of hamachi lol

Is setting up a simple server a cumbersome amount of code? Does anyone have any example code?

Also, i have this idea that "servers" are a fairly uniform thing that all multiplayer games have... Is that not the case? Are "servers" just a way of handling the communication, and its up to me to systemize it? So each coder's server might be setup totally different, but achieve a similar goal... Like an RPG battle system or something?
 
Last edited:
M

Misty

Guest
UDP is a nightmare, just start by making a simple chat room from TCP. Once you get the basics convert it to UDP then.
 

Surgeon_

Symbian Curator
@Vether My first post was written as a general statement, without much regard towards the reader's skill level.

UDP can be difficult to work with and if you're an absolute beginner to networking, I'd recommend you stick to TCP and adjust your game/program to what TCP can support. Just to be clear, TCP is not bad by any means - for example, World of Warcraft uses TCP (or at least did earlier), and I think that some strategy games do too. But when looked at from the perspective of a developer of a very fast game, like a first person shooter (Counter Strike is a good example - there a quarter of a second can mean difference between killing or being killed), only then TCP can start to look sluggish and burdensome. For your first networking project it's totally fine.
 

Neptune

Member
Gotcha, so i'll start with TCP.
I don't even know what that means (aside from the acronym), buts thats fine for now I guess.

Is a "server" a fixed/consistent structured thing? Or is it a description of functionality?

I don't know how to better phrase that question...
Is there a step by step process to create a server? Or is it like creating a video game inventory system or something?
 

Surgeon_

Symbian Curator
There's not a uniform way to go about creating a server. The server is basically just a means to transfer data between the players. Now, it's the data you transfer that counts, and that depends on the game and it's different every time.
 

Pfap

Member
I tried creating a stand alone server with gml today by creating an .exe and testing. I could not get it connected, I'm not sure why though as I can connect to a php server using the network connect raw function. Getting things setup on a wider area network is time consuming, but I eventually want to make a tutorial on setting up an Ubuntu server to work with Gamemaker for developing. If you are just trying to build a server your friends can connect to, a raspberry pi works fine and is really cheap; it is also plenty fast for small networking tasks, but developing in it can be a pain because it is slow if you are downloading packages like apache and stuff.


What you would need to do though is get a separate computer, Mac or Linux would probably be easiest. (Linux seems more open to letting a newbie do whatever, while Windows has a bunch of steps and there seems to be more fluff to deal with, but I really have no clue. Mac also has a terminal and is more unix based although I don't have much experience there.)

Then you would connect that computer to the network (which probably means you will run an ethernet cord from your router to your compter) and then login to your router.

From your router you will want to set up a port forwarding service. I use a Netgear router and originally just went to there website and followed the directions it was pretty simple and other router company's should have similar tutorials.

So, lets say you create a service on the router named GM_server that forwards port 8080 from the internal ip of the computer you are going to use as a server; then that means that port 8080 is accessible from the outside network and a direct line in a manner of speaking to that computer.

Now that the port is forwarded you will want to write some service on the server computer to listen for incoming connections on the forwarded port.

Here is probably the simplest and pretty much useless way to connect and the only one I currently have lol. With it you can send a string from gamemaker to the server computer and the server computer will send it back to you.
You can do operations on the string once it reaches the server if you want.

This is Php code.
Code:
<?php


$host = "192.168.1.2";
$port = 8080;
// No Timeout
set_time_limit(0);
//create socket change to udp non stream after playing with this
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
//bind socket to host and port
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
//start listening
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n");


//accept incoming connections
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
echo "we have a connection";
//read what the client sent us
$input = socket_read($spawn, 1024) or die("Could not read input\n");

//send what I sent back to me or change it here something like $output."My string reached the server and added this."
$output = $input;
//return message to the client
socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");

socket_close($spawn);

?>

There are a bunch of other steps to installing Php and the php runner; I'm not sure if installing php lets you run php scripts independently.
Then saving the script someplace and running it from the command line or as a service.

There are lots of useful resources about installing php and running services though.
I've personally used some of the Digital Ocean tutorials.

Edit:

Technically you would not need a separate computer, but half the fun of using a cheap system or computer open to the network is not caring what happens to it and a lot of the things I do are probably hacky and bad practice, but I guess I have to learn somehow lol. And your main computer is probably not something you want to be abusing.

Also, it would be awesome if you could use GML on the server in the same manner as the Php above. Or just as a separate language not with Gamemaker, but learning a new language is kind of fun and keeps things fresh.


Edit 1:
In my above example I forgot to mention that the server will be listening on port 8080 of it's private ip and then the gamemaker client will connect using the public ip.
 
Last edited:

Neptune

Member
@Pfap Wow thanks for that reply!

Ive definitely got a lot to learn here.

So, if someone makes a multiplayer game, they probably have some kind of computer(s?) specifically as a server for their players?
 

Pfap

Member
There's always a niche and value in older knowledge. We used to plow fields with horses, so what I'm about to say is pure conjecture. But, Ipv6 has been around since the late 90's per this link from engineers at Activision http://alumnus.caltech.edu/~dank/peer-nat.html and it has taken more than 20 years and it is still not fully implemented. I feel that authoritative is the future, so it is best to learn that and server administration, as there will always be demand for it.
NAT has always, again IMO been the shortfall of IPV4; whoever came up with ipv4 also came up with the biggest bandaid in the history of humanity with NAT. It's a solution to extend a limited number of addresses... like why not just add more addresses? Which is a question better to be answered by people with more knowledge than me, but yea my above template as far as I can tell works with basically all languages.
There are a lot of frameworks and people working on simplifying multiplayer game servers; check out pomelo and sails for node and swoole and kraken for php. Things keep getting easier for the layman and Pomelo practically advertises itself as just as good as a low level solution (c and c++) and is currently among the solutions I am currently looking into.

To specifically answer your question: yes they have 1 or multiple computers and 1 or more frameworks and plugins designed by numerous people to run their multiplayer game and the good thing is that a lot of them are open source and available to everyone.

There is always going to be lag and I am pretty amazed at the amount of engineering that went into COD black ops 4, but you can definitely accomplish a multiplayer game with a little focus.


p.s
As your original post stated: [qupte] Anywhere I look where people ask similar questions, they get the "Too broad, you're dumb," reply.
Or the "There are 100 ways to do it, but they're all super slow and impossible," reply.[/quote] I am particularly disappointed in the current way "newbs" are treated when they ask a networking question. It took a lot of engineering and people to get where we are and it is unrealistic to think anyone could understand it overnight... but if you work on a farm nobody and I do mean absolutely nobody is going to explain how we used to use horses to plow fields. ( maybe the Amish )



My current mental "block" consists of what happens when a client "connects" to a udp server? Can the server respond independently of the response/request system? I thought udp was connectionless? If it is connectionless wouldn't that mean that the client would need to be "listening" for the server's response? And you can't expect users of your app to take time to port forward your apps needed ports. Which is also a problem that may not be needed to fix since port forwarding is only needed to overcome NAT! So, this is kind of just a rant. But, my point is that people have just been doing what "works" for a long **s time. Figure that out and you are good.



*sidenote
I know you can turn udp into tcp by building your own protocol on top of ip. (so, salty about networking... so salty)
Connection is basically a handshake you need a college degree to understand (I disagree)

...ok rant over.
 
Last edited:

Neptune

Member
@Xer0botXer0 Ty ill look at those! That article is really helpful.

@Pfap So, good rant... Im wondering about posts ive seen where people have said something like, "do most of the heavy lifting server-side". This seems counter intuitive to my way of thinking, which would be to have my server collect and distribute minimal amounts of data, and take advantage of the client's PC (regardless if the server is dedicated or not).
 

Xer0botXer0

Senpai
The main thing about having most of the code run server side is for security. Where clients are just viewers that is provided just enough options to play the game.
But that is a lot of extra coding. Which I chose for the heck of it. There is a line though,you want to compare values player sends the server with a server copy, just in case a player is trying to place a stack of 10,000 ore in a chest when he only actually has 32. The other side of the line is where a player can change his username with a trainer or such, if it doesn't have a major impact then don't check that.

I've seen silly things in mmos where players can teleport around by manipulating their coordinates and nothing is checked server side.
 

The-any-Key

Member
I am particularly disappointed in the current way "newbs" are treated when they ask a networking question
While I understand the frustration I also understand why people can become jerks when answering "newbs" questions about network. Sometimes I got questions how to do a multiplayer game. But the question in itself is impossible to answer. I can start asking what game they have in mind and what the goal are. And often it ends up that they actually want a MMO architecture. But you can't explain how a MMO architecture is done by chat or posts on a forum. And some wonder why I can't explain it in some simple terms or what lines of code they need to write. And it's around here people get a bit crazy. You want to explain in a nice manner that network coding is is not a simple task that is explained and done over night. And just a few lines of code will not cover this. And this works both ways. You need to respect the newcomers. But the newcomers also need to respect the ones with the experience and not just think that they are being told that they are dumb. Or that we don't want to help them. It's just that this is not a straight forward thing. So you need to narrow down the question and exactly explain how you network game will work.

A good example of what a network connection actually is. Is that it is like making a phone call. You can talk to the game on the other end and you can make the game talk back. A common misunderstanding is when you make a network connection. The games are connected, and all you need is a connection to make a multiplayer game. But this is not true. The only thing a network connection do. Is to allow you as a coder to send data from one end to the other. And that is all. When the data is received on the other end. You as the coder need to do something with it. Else nothing will happen. This is a fundamental truth about multiplayer games.

My current mental "block" consists of what happens when a client "connects" to a udp server? Can the server respond independently of the response/request system? I thought udp was connectionless?
UDP need a "connection line" or tuple line. This is a line in the routers and NATs that go from your computer to the other. And this invisible line is only open while data is flowing. When you stop send data, this line will die after 30-60 seconds. And if you try send data after that time has ended. The data may not be received. So UDP need "connection".
 

FrostyCat

Redemption Seeker
As your original post stated: Anywhere I look where people ask similar questions, they get the "Too broad, you're dumb," reply.
Or the "There are 100 ways to do it, but they're all super slow and impossible," reply. I am particularly disappointed in the current way "newbs" are treated when they ask a networking question. It took a lot of engineering and people to get where we are and it is unrealistic to think anyone could understand it overnight... but if you work on a farm nobody and I do mean absolutely nobody is going to explain how we used to use horses to plow fields. ( maybe the Amish )
Yet when experienced users are asked questions about networked games, most of the time the question is phrased in a way assuming that there is a one-size-fits-all solution that could be instantly understood. That pisses us off. And just as often, they come in not even knowing how to forward ports on a router, or the fact that 192.168.x.x addresses are private, or the fact that 127.0.0.1 points back to themselves. That pisses us off even more.

One thing that I now demand of all networking novices is an understanding of procedures in correspondence chess, even if they don't all play chess. That's the closest physical analogue of how actual multiplayer games work, and it stops dead most rookie myths about multiplayer games. The connection is not a shared board between the players on a table, it's just the mailman in a correspondence game. Nothing happens on your board until you act upon mail sent out by your opponent. Nothing happens on your opponent's board until you send him/her mail stating what your move is. And for the same reason you can't use chess notation in backgammon, bridge or StarCraft, you have to tailor the form and notation to the game.

Yet when I break out the inconvenient truth that there's no silver bullet, often the rookies go into conspiracy mode. They continue to believe there's an automated secret that we're hiding from them, and keep pressing us for the "automagical" solution that can be blindly plugged even into unoptimized architecture. That's when longtime responders like me to get ornery about it and start responding the way you described.

If you want people with networking experience to stop demeaning rookies, rookies need to purge ideas like "plug-and-play", "automagical", "universal" and "one-size-fits-all" from their mental image of network programming. Then they'd ask questions in a way that we'd answer with purpose and mercy.

So, good rant... Im wondering about posts ive seen where people have said something like, "do most of the heavy lifting server-side". This seems counter intuitive to my way of thinking, which would be to have my server collect and distribute minimal amounts of data, and take advantage of the client's PC (regardless if the server is dedicated or not).
You'd stop thinking this way the instant you learn any form of networking attack, even something as simple as spoofing the From: field on SMTP. This is something that every student learning networking in a formal setting would have done at least once, and there's a good reason why it's taught.

The cardinal rule in any sort of server-client architecture involving untrusted parties is that server-bound messages must be assumed false unless proven true. This is especially true in any situation where there's a benefit to be had in falsifying a message.
 

Pfap

Member
While I understand the frustration I also understand why people can become jerks when answering "newbs" questions about network. Sometimes I got questions how to do a multiplayer game. But the question in itself is impossible to answer. I can start asking what game they have in mind and what the goal are. And often it ends up that they actually want a MMO architecture. But you can't explain how a MMO architecture is done by chat or posts on a forum. And some wonder why I can't explain it in some simple terms or what lines of code they need to write. And it's around here people get a bit crazy. You want to explain in a nice manner that network coding is is not a simple task that is explained and done over night. And just a few lines of code will not cover this. And this works both ways. You need to respect the newcomers. But the newcomers also need to respect the ones with the experience and not just think that they are being told that they are dumb. Or that we don't want to help them. It's just that this is not a straight forward thing. So you need to narrow down the question and exactly explain how you network game will work.

A good example of what a network connection actually is. Is that it is like making a phone call. You can talk to the game on the other end and you can make the game talk back. A common misunderstanding is when you make a network connection. The games are connected, and all you need is a connection to make a multiplayer game. But this is not true. The only thing a network connection do. Is to allow you as a coder to send data from one end to the other. And that is all. When the data is received on the other end. You as the coder need to do something with it. Else nothing will happen. This is a fundamental truth about multiplayer games.


UDP need a "connection line" or tuple line. This is a line in the routers and NATs that go from your computer to the other. And this invisible line is only open while data is flowing. When you stop send data, this line will die after 30-60 seconds. And if you try send data after that time has ended. The data may not be received. So UDP need "connection".

Yea, I get that especially when somebody is pretty much completely new to programming. But, I feel even someone who has been using gml to build non-networked apps for 2-3 years can be just as lost when it comes to networking even when they understand the basics of programming. I guess what I want is D'n'd networking lol... that just works LOL!
 

Pfap

Member
Yet when experienced users are asked questions about networked games, most of the time the question is phrased in a way assuming that there is a one-size-fits-all solution that could be instantly understood. That pisses us off. And just as often, they come in not even knowing how to forward ports on a router, or the fact that 192.168.x.x addresses are private, or the fact that 127.0.0.1 points back to themselves. That pisses us off even more.

One thing that I now demand of all networking novices is an understanding of procedures in correspondence chess, even if they don't all play chess. That's the closest physical analogue of how actual multiplayer games work, and it stops dead most rookie myths about multiplayer games. The connection is not a shared board between the players on a table, it's just the mailman in a correspondence game. Nothing happens on your board until you act upon mail sent out by your opponent. Nothing happens on your opponent's board until you send him/her mail stating what your move is. And for the same reason you can't use chess notation in backgammon, bridge or StarCraft, you have to tailor the form and notation to the game.

Yet when I break out the inconvenient truth that there's no silver bullet, often the rookies go into conspiracy mode. They continue to believe there's an automated secret that we're hiding from them, and keep pressing us for the "automagical" solution that can be blindly plugged even into unoptimized architecture. That's when longtime responders like me to get ornery about it and start responding the way you described.

If you want people with networking experience to stop demeaning rookies, rookies need to purge ideas like "plug-and-play", "automagical", "universal" and "one-size-fits-all" from their mental image of network programming. Then they'd ask questions in a way that we'd answer with purpose and mercy.


You'd stop thinking this way the instant you learn any form of networking attack, even something as simple as spoofing the From: field on SMTP. This is something that every student learning networking in a formal setting would have done at least once, and there's a good reason why it's taught.

The cardinal rule in any sort of server-client architecture involving untrusted parties is that server-bound messages must be assumed false unless proven true. This is especially true in any situation where there's a benefit to be had in falsifying a message.

I do know what you mean. I think part of it comes from the disconnect between people who love video games and are more attached to the idea of it than what it really is and I can relate. I'm talking about the people who have been daydreaming about making games for most of their childhood and then they actually get to work or take a course and it is not what they imagined versus the people who think of it as just something they do. With the latter having no expectations or fewer expectations.
Never in my life did I think one day I would be programming or writing games... I wanted to be a professional wrestler and that's what I did for close to 2 years; had a bunch of matches and then realized it was nothing I imagined.
So, a couple of years of college and problems with physics and biology and I somehow landed on programming and I do enjoy it, but I'm not attached to it. It is fun, but I never had any dreams of making an MMO or actually any game... so, I feel it is easier for me to just objectively look at it how it is and not how it should be.

And I was thinking about your horses to water statements when I made up mine lol, but you always post useful content along with your rants so, you're cool.
 

Neptune

Member
You'd stop thinking this way the instant you learn any form of networking attack, even something as simple as spoofing the From: field on SMTP. This is something that every student learning networking in a formal setting would have done at least once, and there's a good reason why it's taught.
I've seen you mention security quite often, and from the brief professional instruction I had with web dev, I got to see where security/validation is important. However, I don't see how security applies to this, or even most multiplayer games.
This is not a comment saying "You're wrong!". I just don't see what you mean, please elaborate.

If I were making a stupid stick-people shooter platformer game (say 8 people jumping around killing each other in a box), my first thought would be to have each player send little pieces of information that are action/movement commands to the server (coordinates,shoot,jump,die,etc), and then those commands would be distributed, and everyone's player_instances would be updating accordingly... That being said, where does security come into play here?
 
Well, I'd guess it'd be because people could hack into the packets and change the numbers they're sending out, allowing them to teleport around/infinite ammo/whatever. So part of the security process is the server verifying whether each command is within the rules of the game and only updating every clients game when those conditions match. This is at least a part of what I imagine Frosty means by server-bound messages must be assumed false until proven true.
 

Mert

Member
Noone mentioned but there's a big big obstacle that is Game Maker Studio itself. Creating a decent server with GMS is "impossible". These are written hundreds of times here, but once again:
  1. Game Maker's core wouldn't let you run your application in big servers(VPS etc.), because most of these machines do not have required hardwares to run your application(Video card). They were meant to host logic-based applications and do not need such hardwares. GM applications require video card to be run.
  2. Game Maker's single threaded applications may not be enough to process your data. There'll be lots of packages will come and go. I wrote a c++ server back in 2012 to test out how it looks and I got more performance with a multithreaded server.
  3. You have less control over the network packages, but this is less irrelevant since that wouldn't effect the gameplay anyways.
  4. There's a thing with Async events, they're not actually asynchronous. They are actually equal to User Defined Events because each of these events get triggered one step at the time they get received. I mean in a 60 fps game, if you're between 3rd and 4th step, you must wait for 4th step to come in effect, and then you receive your data. You may say "it's okay, it's just 0.00000001 seconds (just giving an example), but if you're receiving lots of data, of course this is a problem.
Solution is:
  1. Use big data providers. Google Play Service's APIs are a decent way although they're not the best. Realtime Multiplayer API is somehow good and bad at the same time. Also, if you can make an extension for it Amazon GameLift or PlayerIO are real good. Unity has libraries for these and supported well, GMS unfortunately has no SDKs for them. You'd have to make your own, or request Yoyogames to do it(They won't ;))
  2. Gamemakerserver.com is a FREE service that lets you make a multiplayer game easily with no-real networking knowledge. Does not support GMS2 at the moment, but Game Maker 8x and GMS1.4x are working good. It also provides online INI(database), friend system, achievements, scores, analytics and of course realtime multiplayer support.
  3. Google Firebase also lets you make your own online game although be noticed that it is achieved by using tools to do so. It means that Firebase has no support for online game servers, but has tools that you can use. A common example is in-game chat and pingpong application that you can achieve through Firestore(real-time database) and Functions. There's an extension in the marketplace that allow you to do, but it's too expensive. I am currently working on a FREE Full Firebase extension(along with Machine Learning Kits), just working on it.
Less Effective Solution is:
  1. Create your server on GMS and get an Ubuntu export. You may be lucky that your application may run on a Ubuntu server. The plus side of this is that you can achieve better Server-sided logic on your game since you're handling some, let's say collisions or some other stuff on Game Maker, and doing it on is more easy.
 

Neptune

Member
@RefresherTowel I see. Is there something about how data packets are transmitted across a connection that makes them prone for tampering?
Could i encrypt the data and call it a day?


@Mert thanks for the info. I dont have any experience with any of this yet, so im fine with just working with GMS (atleast until i have a decent understanding).
 

Dog Slobber

Member
In this topic and in many topics the recommendation by many is to use UDP over TCP because it's faster.

This is not good advice. I'm not claiming TCP is faster, it's not. But for reasons @Mert said and more, using TCP (over UDP) will not be the bottleneck. In a non-congested environment, the slower mechanics of TCP aren't relavent, and the speed differnece doesn't apply. UDP is often used for applications where some data loss is acceptible. But it's also used for streaming applications like video and audio that generate a lot of data and contibute to a lot of congestion. Video games should not be generating anywhere near the data that typical streaming applications do.

Writing in UDP is immensely more complicated, especially if you want to create any of the reliability functionality of TCP. With UDP you need to write NAT traversal or instruct users to either port forward or trigger.

NAT has always, again IMO been the shortfall of IPV4; whoever came up with ipv4 also came up with the biggest bandaid in the history of humanity with NAT. It's a solution to extend a limited number of addresses... like why not just add more addresses?
NAT wasn't created by the creators of TCP/IP, is was created well after. And you can't just add addresses. The limiting factor for the number of addresses is the 32 bit field size in the IP header.


@RefresherTowel I see. Is there something about how data packets are transmitted across a connection that makes them prone for tampering?
Could i encrypt the data and call it a day?
In the context of client/server game security, packets are not being manipulated in transit.
 
Last edited:
Top