Read from Socket for x Items Problem

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Read from Socket for x Items Problem

Post by mikelpapamike » Sun Jul 23, 2023 10:27 pm

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.

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: Read from Socket for x Items Problem

Post by Emily-Elizabeth » Sun Jul 23, 2023 10:47 pm

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 ";"

mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Re: Read from Socket for x Items Problem

Post by mikelpapamike » Mon Jul 24, 2023 7:49 am

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 .

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Read from Socket for x Items Problem

Post by dunbarx » Mon Jul 24, 2023 8:39 pm

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

mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Re: Read from Socket for x Items Problem

Post by mikelpapamike » Mon Jul 24, 2023 11:37 pm

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 .

mikelpapamike
Posts: 32
Joined: Sat Feb 27, 2021 12:17 am

Re: Read from Socket for x Items Problem

Post by mikelpapamike » Tue Aug 01, 2023 1:23 pm

So there is no way to read specific number of items from socket and set the item delimiter in socket?

Post Reply

Return to “Internet”