Page 1 of 1

Socket server

Posted: Tue Aug 22, 2017 11:29 am
by rblackmore245
Has anyone managed to write a good multiuser socket server in livecode.

Managed to write one that works great for small amounts of data but having issues with large packets of base64 strings that are split into multiple messages sometimes 30+.

I prefix the data with a username (where its going to ) and who its from and then the server app looks this up against what socket that username is associated with and forwards that data to that socket.

But the issue i'm having is when a lot of data flows through it is slit up into lots of messages and I loose the prefix username and from data.

Anyone ever done this type of app before ?

Re: Socket server

Posted: Tue Aug 22, 2017 1:18 pm
by MaxV
You could prepend the seconds or the millisecods, for human beings are quite unique.

Re: Socket server

Posted: Tue Aug 22, 2017 3:46 pm
by FourthWorld
How large is that base64 data?

Re: Socket server

Posted: Wed Sep 06, 2017 12:40 pm
by rblackmore245
It looks like the maximum data length that can flow through livecode sockets is 8192 can anyone confirm this ?

Re: Socket server

Posted: Wed Sep 06, 2017 3:27 pm
by FourthWorld
rblackmore245 wrote:It looks like the maximum data length that can flow through livecode sockets is 8192 can anyone confirm this ?
Where did you read that?

Re: Socket server

Posted: Wed Sep 06, 2017 4:51 pm
by rblackmore245
just trying to do some tests and sending a large amount of base64data through the socket and it always gets cut at 8192.

Re: Socket server

Posted: Wed Sep 06, 2017 5:30 pm
by FourthWorld
rblackmore245 wrote:just trying to do some tests and sending a large amount of base64data through the socket and it always gets cut at 8192.
It may be useful to see the code. I rarely use sockets directly, but have done a lot of work with HTTP, which LC's libURL handles using the engine's socket calls. It's been rare that I send anything smaller than 8192, often a few MBs.

Which LC version are you using?

Re: Socket server

Posted: Thu Sep 07, 2017 9:22 am
by rblackmore245
Hi Richard,

The code is nothing complicated just using all the examples from the livecode website more data will flow from the socket but I find that unless you call

"read from socket pSocket with message "messageReceived"" a the end of the function it stops at this limit.

But I suppose this makes sense as it would lock the function if a large data was flowing through the socket waiting for all the packs to be received.

Sorry kinda answered my own question there.

Re: Socket server

Posted: Thu Sep 07, 2017 6:04 pm
by FourthWorld
rblackmore245 wrote:Hi Richard,

The code is nothing complicated just using all the examples from the livecode website more data will flow from the socket but I find that unless you call

"read from socket pSocket with message "messageReceived"" a the end of the function it stops at this limit.

But I suppose this makes sense as it would lock the function if a large data was flowing through the socket waiting for all the packs to be received.

Sorry kinda answered my own question there.
Glad that worked out, but LC should be able to handle both blocking and non-blocking socket comms.

The non-blocking "with message" form is most commonly used, but there are times when blocking is useful. In those cases we need to either read for a specific length, or for a specific delimiter, which may include EOF.

Without knowing whether you used length or a delimiter I can't guess as to what went wrong before, but if non-blocking is what you need you've found the best form anyway.