Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / is a AddNetworkMessageByte send as byte or integer?

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 26th Sep 2022 13:30
I know I can read and write it as a byte, but under the hood, does it get sent as an integer or a true byte? I am asking because I am optimizing my network code, sending a single byte should be better than sending a 32bit integer (4 bytes). I even pack my bytes with individual bits if I don't need a full byte so that a byte can contain more than 1piece of information.
13/0
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Sep 2022 22:30
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 27th Sep 2022 05:47 Edited at: 27th Sep 2022 05:48
cybermind,

this stuff is a bit beyond me but a skim of Network.cpp seems to show integer (UINT)?

ie, @ CheckMessagesServer, i see GetBytes() followed by RecvUInt()

perhaps you can make more sense of the source than i so figured i'd direct you to it.
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 27th Sep 2022 09:36
In the days of Dialup every byte mattered and sending a int when a byte is required is wasteful, maybe packing four bytes into a int and sending that would be better
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 28th Sep 2022 12:38
I am trying to make speed-optimized multiplayer code, so if each added byte is still handled as a 32-bit integer and possibly with a bit of overhead for each value added to the message, I might as well pack all 4 bytes into one 32-bit integer sending only one integer with its overhead (plus all the other overhead for the packet itself, of course).
13/0
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 28th Sep 2022 13:26
AddNetworkMessageByte() will only send a single byte over the network
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 3rd Oct 2022 10:05
Thank you, it is good to know Is there any overhead for each byte? Something telling the receiving end that only a byte will be sent?
13/0
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Oct 2022 11:59
Quote: "Is there any overhead for each byte? Something telling the receiving end that only a byte will be sent?"

Nope, the receiver has to assume the format of the message to read it correctly, or you can add your own values to tell the receiver what to expect
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Oct 2022 10:51
Quote: "Nope, the receiver has to assume the format of the message to read it correctly, or you can add your own values to tell the receiver what to expect "


Ah, yes, that makes sense, that's what I am doing when I read packets. Thanks for the clarification
13/0

Login to post a reply

Server time is: 2024-11-23 08:06:47
Your offset time is: 2024-11-23 08:06:47