Socket splitting data

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Socket splitting data

Post by mikelpapamike » Tue Dec 13, 2022 10:10 pm

Hello everyone,

I'm currently trying to build an App that connects to a 3rd party software which provides some data in json format. Then I translate the json data to xml and send them via socket to a socket server I built based on the chat server/client sample stack in order to broadcast the XML array to multiple clients that are connected to chat server. But the server broadcasts the whole xml data in 2 messages instead of one, this way I don't know when all the data have been received on the client in order to start manipulating them and clear buffer to wait for the next message(updated xml data).

When I receive the data in json format I run a .bat file that translates them to xml and stores it in a file in order to read them elsewhere.

The reason I can't share the folder of the file with the clients is that some of them may be over internet, so on the chat server I can port forward and have all clients connect to it and receive the messages, plus I want the lower possible delay.

Any idea why my socket message is being split? Is there a size limit that can be increased ?

Thanks in advance.

mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Re: Socket splitting data

Post by mikelpapamike » Wed Dec 14, 2022 2:25 pm

The only way I managed to know when ive sent all the data, is to add a special character like "^" and wait until "^" at the client side, but I dont know what will happen if the data will contain somewere this character. :?:

mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Re: Socket splitting data

Post by mikelpapamike » Fri Jan 27, 2023 7:03 pm

Thats the issue that I need to use a character that I will be 1000% sure that will never be used!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Socket splitting data

Post by jacque » Sat Jan 28, 2023 7:40 pm

I like numToChar(8) which is the delete key. It isn't typeable and will never appear in any text. NumToChar is deprecated but still works, but if you want to be technically correct you can use numToCodepoint instead to do the same thing. NumToChar(3) is another option which also can't be typed.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Socket splitting data

Post by mwieder » Mon Jan 30, 2023 12:57 am

I tend to use NumToByte(3) and NumToByte(4) quite a lot for transmission control chars.

Packet size is determined by the operating system's MTU setting (nominally 1500 bytes) but note that it may be negotiated across intervening routers. But if you're communicating with a remote server then it's in control of the packet size it sends to you.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Socket splitting data

Post by SparkOut » Mon Jan 30, 2023 4:42 am

I have often wondered why people don't ever seem to use ASCII 28 to 31, which comprises a group of codes originally designated as separators (record, unit, etc).
Is there a reason that these codes seem ostracised?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Socket splitting data

Post by mwieder » Mon Jan 30, 2023 6:36 am

It's an extra character to type, and programmers are by nature lazy.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Socket splitting data

Post by SparkOut » Mon Jan 30, 2023 8:24 am

How is it more to type than ASCII 3 or 4?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Socket splitting data

Post by mwieder » Mon Jan 30, 2023 8:46 am

"NumToByte(3)" = 12 chars
"NumToByte(28)" = 13 chars
<g>

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Socket splitting data

Post by SparkOut » Mon Jan 30, 2023 10:55 am

:lol:
Oh well.

I am really curious whether there is a serious reason why (apparently) nobody in the world uses these delimiters though.

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Socket splitting data

Post by Klaus » Mon Jan 30, 2023 11:03 am

Call me "nobody" :-)

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Socket splitting data

Post by mwieder » Mon Jan 30, 2023 7:19 pm

It *is* a good question.
I got into the habit of using NumTtoByte(4) because it's defined as EOT.
But I haven't given much thought to the 28->31 chars.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Socket splitting data

Post by jacque » Mon Jan 30, 2023 7:40 pm

I'm a nobody too, never thought about the 28-31 set.

Am I correct that we can use numToByte for any ascii code up to 256? When do I need numToCodepoint?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Windows”