Page 3 of 3
Re: Timing over socket connection
Posted: Wed Jan 11, 2023 8:53 pm
by trevix
Not until the buffer is full on the receiving end. If the buffer is full, no more data can be written until some data is read
Should not be my case, since the data is less then 100k and regularly read by the receiving end.
If you try to read an empty buffer you'll just get an empty value unless you told it how much to read or to read until it encounters a specified chunk, in which case it will wait until the specified amount of data is received or until the chunk is encountered.
I use chunk at the end of the data.
Code: Select all
read from socket p_Socket until kEndOfFile with message "chatServerMessageReceived"
So if I do such a read and there is no data to read, the script will hang for a SocketTimeoutInterval?
I can then clear the buffer with a
without specifying the kEndOfFile?
Re: Timing over socket connection
Posted: Wed Jan 11, 2023 9:03 pm
by Cairoo
when doing such a read without specifying a callback message, the script would hang until a socket timout. In your case you did specify a callback message, so the script continues immediately and the callback handler will be called later whenever the data has arrived.
Re: Timing over socket connection
Posted: Wed Jan 11, 2023 9:18 pm
by Cairoo
trevix wrote: Wed Jan 11, 2023 8:53 pm
I can then clear the buffer with a
without specifying the kEndOfFile?
Yes that's how you'd read from the buffer to clear it of data you'd like to discard. But then perhaps you'd do it in a repeat loop until it is empty, just to be sure.
Code: Select all
read from socket p_Socket
repeat while it is not empty
read from socket p_Socket
end repeat
Edit: After a socket timeout I think it's safe to assume there's no more data to be read, because it was waiting for more data that did not arrive.
But then the data could still be on its way so there's no guarantee the buffer won't contain data shortly after the timeout.
Re: Timing over socket connection
Posted: Fri Jan 13, 2023 5:19 pm
by trevix
Read from socket p_Socket
cannot be compiled because does not have a termination condition specified.
The script editor does not accept it.
Re: Timing over socket connection
Posted: Mon Jan 16, 2023 8:19 am
by Cairoo
I didn't test it before posting. I've only ever used it with a callback message and it turns out that the form without a condition can only be used with a callback message.
Code: Select all
read from socket p_socket with message dataReceived
I wanted to blame it on the dictionary. This time I can't.
Re: Timing over socket connection
Posted: Mon Jan 16, 2023 11:34 am
by trevix
Yeah, adding "with message dataReceived" to all my read solved all my problems apparently.
Thanks
Re: Timing over socket connection
Posted: Mon Jan 16, 2023 6:57 pm
by mwieder
Thankfully the script compiler is smart enough to catch the error.
And yes, the "read from socket" command needs either an "until xxx" clause or a callback mechanism.