I am working on writing a socket client on the FANUC side to talk to a Python server. I got the example code to work, but I am having issues with getting a random length string to be passed to and from.
Code
tmp_str = 'Connect'
WRITE file_var(tmp_str::126)
WRITE('Wrote: ',tmp_str,CR)
WRITE('Waiting to read from server...')
READ file_var(tmp_str::126)
status = IO_STATUS(file_var)
WRITE('Read status: ',status,CR)
works if my Python server echoes the data back
But if I want the response from my server to be "Connect, 1"
Then the Karel client is stuck on "waiting to read from server..." because it is expecting more bytes. I tried to use BYTES_AHEAD to sniff how many bytes to read, but that function returned 0. However, if I change my READ to
it works fine. From the manual I thought the first format specifier was the number of bytes to read. This appears to be the length of the string. How do I know a prori the length of the input string buffer?