Read from Socket for x Items Problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Read from Socket for x Items Problem
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.
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.
-
- Posts: 97
- Joined: Mon Jan 03, 2022 7:10 pm
Re: Read from Socket for x Items Problem
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 ";"
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Re: Read from Socket for x Items Problem
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 .
-
- VIP Livecode Opensource Backer
- Posts: 9313
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Read from Socket for x Items Problem
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
Craig
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Re: Read from Socket for x Items Problem
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 .
-
- Posts: 32
- Joined: Sat Feb 27, 2021 12:17 am
Re: Read from Socket for x Items Problem
So there is no way to read specific number of items from socket and set the item delimiter in socket?