Page 1 of 1

Read from Socket for x Items Problem

Posted: Sun Jul 23, 2023 10:27 pm
by mikelpapamike
Hello everyone,

I came up to a strange issue. I’m opening a socket to receive connections and data from a client that connects. The program that sends the data does not have a termination pattern/character/line etc , so I’m trying to read it based on the items it sends that are separated with “;” character.

So I use “Read from socket x for 10 items” but no matter what number I set after “for” I get the same items. Is there a specific way to set the item delimiter on sockets? I tried on the command that reads incoming data to “set the itemdel to “;” but it makes no difference.

I’m Using livecode 10.0 dp4

Thanks in advance.

Re: Read from Socket for x Items Problem

Posted: Sun Jul 23, 2023 10:47 pm
by Emily-Elizabeth
You can always read for each item by reading to the ItemDelimiter character

Code: Select all

read from socket "127.0.0.1:80" until ";"

Re: Read from Socket for x Items Problem

Posted: Mon Jul 24, 2023 7:49 am
by mikelpapamike
Yeah I thought about it, but because the data will contain timer in fraction of milliseconds I was worried if there will be any performance issue reading each item separately .

Re: Read from Socket for x Items Problem

Posted: Mon Jul 24, 2023 8:39 pm
by dunbarx
I assume you do not need to work with each "item" as it comes over, so cant you read it the whole thing and do the parsing work "back" in LC afterwards?

Craig

Re: Read from Socket for x Items Problem

Posted: Mon Jul 24, 2023 11:37 pm
by mikelpapamike
What do you mean ? I tried to just read from socket without any “for” or “until” but until the client disconnects I don’t seem to be able to put those incoming data to a field.As the “read from socket x with message “messageReceived” “ won’t exit until client stops sending data. And it sends at a fraction of milliseconds .

Re: Read from Socket for x Items Problem

Posted: Tue Aug 01, 2023 1:23 pm
by mikelpapamike
So there is no way to read specific number of items from socket and set the item delimiter in socket?