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 / [BUG] AGK UDP Message possibly broken?

Author
Message
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 12th Mar 2019 18:55 Edited at: 12th Mar 2019 18:56
Hi folks,

I wanted to test the new UDP commandset and found out, that at least the AddNetworkMessageInteger command is possibly broken

Beside the other network stuff, I created following message:
AddNetworkMessageInteger(iMsgID, val("FFFFFFFF",16) )

But I recieved: FFFFFF7F
Even with multiple Integers.

When I added this as a message:
AddNetworkMessageInteger(iMsgID, val("FFFFFFFF",16) )
AddNetworkMessageInteger(iMsgID, val("FF000000",16) )
AddNetworkMessageInteger(iMsgID, val("FFFFFFFF",16) )

I recieved 3 times "FFFFFF7F" - that is even worse than a missing half - byte.

I thought my reciever was broken, but I managed to find the free tool "Packet Sender", and it worked as expected.


My basic test code is:


Do I have some logic error in my code?

Greetings,
Jack

[/url]
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 13th Mar 2019 11:33 Edited at: 13th Mar 2019 11:36
I think the integer is signed in AddNetworkMessageInteger, giving you a "half" integer below zero and a "half" integer above zero.
13/0
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Mar 2019 11:40 Edited at: 13th Mar 2019 11:46
I thought this would be no problem, because the TCP commands are working like they should do.
There should be no difference between signed/unsigned bytes on the network level, but I think there might be a problem there, inside the UDP code of AGK.
Good point.

Is there some sort of quick work-around?
I just want to send FFFFFFFF and recieve FFFFFFFF

[/url]
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 13th Mar 2019 11:53
What I do is take the value and move it inside the range of a 4 byte signed integer and then move it back when received (subtracting a half 4-byte integer and then adding back the half 4-byte integer when receiving). But if you are doing this in Tier 1 I don't think you can have an integer above the signed range, you would have to do it in Tier 2 where you can control whether or not the integer is signed.
13/0
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Mar 2019 23:35
You could just send it as a string then convert
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 14th Mar 2019 22:17
I tried the string, idea,
and all chars above chr(127) or 7F are creating a second following byte in the udp message.
- The string command has also a unsigned/signed bug.

[/url]
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 17th Mar 2019 13:54
So no quick work- arounds found.
I should start to inspect the udp network message code on git...

[/url]
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 19th Mar 2019 11:54
If you take a regular integer variable, that also will only be able to store a 4 byte signed integer. So even if you manage to send an unsigned 4 byte integer, the signed integer variable can still not store it in Tier 1. You will have to move to Tier 2 where you can decide what type the integer should be, once you've done that, you can just subtract a half 4 byte integer before sending it (because the command AddNetworkMessageInteger can only take a signed integer) and then add a half 4 byte integer after receiving it.
13/0
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 19th Mar 2019 18:10 Edited at: 19th Mar 2019 18:12
In order to recieve unsigned bytes in T1, I use the following idea:



But this works only with incoming bytes on TCP connections.
(Actually never tried this on UDP, because I only need outgoing messages right now)

The problem is only to send them by UDP.
On the TCP site, you could go along with:

to send unsigned bytes.

[/url]
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 20th Mar 2019 18:03
Using sockets you can add a byte, UDP uses network message commands where the smallest amount you can add is a 4-byte integer (if I recall correctly). If you just want to send data out from an AppGameKit app and receive it from some other app I think you can use sockets, then you can work out the bit pattern for what you want to send and just send whatever value that is as a signed 4-byte integer, and then on the receiving end of the socket thing just read it as an unsigned 4-byte integer. If you want to send hexadecimal you might have make your own function that converts from hexadecimal to a signed integer that you can send, again, use a bit pattern. I use a bit pattern for my UDP commands, but I do that so I can pack several different pieces of information into one byte.
13/0
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Mar 2019 20:03
Val will convert from hex to decimal.
Just use val(string, 16)
Binary is val(string, 2)

Login to post a reply

Server time is: 2024-11-23 01:50:51
Your offset time is: 2024-11-23 01:50:51