GLBasic forum

Main forum => Bug Reports => Topic started by: FutureCow on 2009-Nov-06

Title: Transmitting CHR$(0) across sockets doesn't work
Post by: FutureCow on 2009-Nov-06
It appears that transmitting CHR$(0) characters via sockets fails. Rather than replicating all the details, please see the forum post which explains the problem with example code.
http://www.glbasic.com/forum/index.php?topic=3753.msg27399#msg27399 (http://www.glbasic.com/forum/index.php?topic=3753.msg27399#msg27399)
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: Schranz0r on 2009-Nov-06
Try this:

"my message to sent via sockets\r\n"
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: FutureCow on 2009-Nov-07
SchranzOr, sorry, that won't help, I'm trying to transmit a binary file, not a text string.
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: bigsofty on 2009-Nov-07
Ive not used the Network commands yet but as GLB uses C strings I believe, so the networking command thinks when it hits a chr(0) then its at the end of the string. i.e. no more data, when it could be midway.

Simplest way is to encode the binary data into text, which for networking can have advantages if combined with simple compression like RLE.

Or simply convert your bytes to an ASCII hex string

EG...

255 15 0 255 = "FF0F00FF"

Then decode it at other end.
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: MrTAToad on 2009-Nov-07
Or even a 3 character decimal number, eg 000028255
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: FutureCow on 2009-Nov-07
I'll probably go with 2 char hex, it means I only have to double the number of bytes sent which is probably the best (easy) solution. It's a lot easier than trying to MIME encode it or something equally as complex. Hopefully there'll be a GLBasic command solution for it at some point down the track.
Thanks for all the suggestions!!!!
Title: Re: Transmitting CHR$(0) across sockets doesn't work
Post by: Kitty Hello on 2009-Nov-09
It was a bug in SOCK_RECV. It's fixed in the next version.