Socket server
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Socket server
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 ?
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
You could prepend the seconds or the millisecods, for human beings are quite unique.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Socket server
How large is that base64 data?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Re: Socket server
It looks like the maximum data length that can flow through livecode sockets is 8192 can anyone confirm this ?
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Socket server
Where did you read that?rblackmore245 wrote:It looks like the maximum data length that can flow through livecode sockets is 8192 can anyone confirm this ?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Re: Socket server
just trying to do some tests and sending a large amount of base64data through the socket and it always gets cut at 8192.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Socket server
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.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.
Which LC version are you using?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Re: Socket server
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Socket server
Glad that worked out, but LC should be able to handle both blocking and non-blocking socket comms.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.
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn