GML network_send_udp vs network_send_udp_raw

matharoo

manualman
GameMaker Dev.
Under the doc page of network_send_udp_raw, it says this:
The data sent is not formatted by GameMaker Studio 2 in any way and the receiving devices will get the data as a stream which means you will have to handle it yourself.
Let's say I send a buffer using network_send_udp(), and another using network_send_udp_raw(). How would I receive them? What's the difference?
 

The-any-Key

Member
You receive them the same way. But the raw send will not include the 12 game maker header bytes. So if you send it to another game maker game the packet may have been broken apart. Most of the time this is not an issue because using raw often means you want to send it to an external server written in Node, Java... And when you send to an external server online you can only send around 700 bytes (max is around 1500 for most, but some NATs are evil so go with 700). And because the packet is quite small it most of the time stay intact (never had any issues with broken UDP packets). And UDP is packet oriented so the risk is quite small anyway.
 

matharoo

manualman
GameMaker Dev.
You receive them the same way. But the raw send will not include the 12 game maker header bytes. So if you send it to another game maker game the packet may have been broken apart.
So if I only want to communicate between GameMaker games, is it better to use the normal function, or the raw one? What difference do those 12 bytes make? They must be used for something.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
So if I only want to communicate between GameMaker games, is it better to use the normal function, or the raw one? What difference do those 12 bytes make? They must be used for something.
The 12 bytes are a 8-byte header (telling apart this as a GM packet) and then 4-byte packet length. On UDP this doesn't really do much (UDP headers already have a size field), but on TCP this makes sure that you get individual packets instead of data stream that TCP is.
 

matharoo

manualman
GameMaker Dev.
The 12 bytes are a 8-byte header (telling apart this as a GM packet) and then 4-byte packet length. On UDP this doesn't really do much (UDP headers already have a size field), but on TCP this makes sure that you get individual packets instead of data stream that TCP is.
Thank you!
 
Top