Socket server

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Socket server

Postby rblackmore245 » Tue Aug 22, 2017 11:29 am

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 ?
rblackmore245
 
Posts: 60
Joined: Fri Jun 12, 2015 9:42 am

Re: Socket server

Postby MaxV » Tue Aug 22, 2017 1:18 pm

You could prepend the seconds or the millisecods, for human beings are quite unique.
Livecode Wiki: http://livecode.wikia.com
My livecode blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w
MaxV
 
Posts: 1287
Joined: Tue May 28, 2013 2:20 pm
Location: Italy

Re: Socket server

Postby FourthWorld » Tue Aug 22, 2017 3:46 pm

How large is that base64 data?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5308
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Socket server

Postby rblackmore245 » Wed Sep 06, 2017 12:40 pm

It looks like the maximum data length that can flow through livecode sockets is 8192 can anyone confirm this ?
rblackmore245
 
Posts: 60
Joined: Fri Jun 12, 2015 9:42 am

Re: Socket server

Postby FourthWorld » Wed Sep 06, 2017 3:27 pm

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?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5308
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Socket server

Postby rblackmore245 » Wed Sep 06, 2017 4:51 pm

just trying to do some tests and sending a large amount of base64data through the socket and it always gets cut at 8192.
rblackmore245
 
Posts: 60
Joined: Fri Jun 12, 2015 9:42 am

Re: Socket server

Postby FourthWorld » Wed Sep 06, 2017 5:30 pm

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?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5308
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Socket server

Postby rblackmore245 » Thu Sep 07, 2017 9:22 am

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.
rblackmore245
 
Posts: 60
Joined: Fri Jun 12, 2015 9:42 am

Re: Socket server

Postby FourthWorld » Thu Sep 07, 2017 6:04 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5308
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles


Return to Internet

Who is online

Users browsing this forum: No registered users and 3 guests