Socket splitting data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Socket splitting data
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.
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.
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Re: Socket splitting data
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.
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Re: Socket splitting data
Thats the issue that I need to use a character that I will be 1000% sure that will never be used!
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Socket splitting data
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
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Socket splitting data
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.
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Socket splitting data
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?
Is there a reason that these codes seem ostracised?
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Socket splitting data
It's an extra character to type, and programmers are by nature lazy.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Socket splitting data
How is it more to type than ASCII 3 or 4?
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Socket splitting data
"NumToByte(3)" = 12 chars
"NumToByte(28)" = 13 chars
<g>
"NumToByte(28)" = 13 chars
<g>
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Socket splitting data
Oh well.
I am really curious whether there is a serious reason why (apparently) nobody in the world uses these delimiters though.
Re: Socket splitting data
Call me "nobody"
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Socket splitting data
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.
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Socket splitting data
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?
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
HyperActive Software | http://www.hyperactivesw.com