Hi
I try to get data from a system service that communicates over TCP/IP. The following code segments are incomplete but show the structure of my program (you can not test it anyway, as I can not post the service):
If I write my code like this it will work smooth:
However if I try to write it like this, the code will not work:
The second sample returns correct data once, but in the second loop TCP RECV will raise an error 57: Device I/O error. Buffer$ seems empty, EOF is FALSE (before and after second TCP RECV)
My dataOut is a lot shorter than 4096 – so the code in the receive loop is executed only once.
Seems so simple - but I can not make it work. So, what is my mistake? Maybe impossible to do with TCP/IP?
Thanks!
I try to get data from a system service that communicates over TCP/IP. The following code segments are incomplete but show the structure of my program (you can not test it anyway, as I can not post the service):
If I write my code like this it will work smooth:
Code:
tcpHandle = FREEFILE FOR ix = 1 TO 10 TCP OPEN PORT 6713 AT "127.0.0.1" AS tcpHandle TIMEOUT 5000 TCP SEND tcpHandle, dataIn DO TCP RECV tcpHandle, 4096, Buffer$ dataOut = dataOut + Buffer$ LOOP WHILE (LEN(Buffer$)<>0) AND (EOF(tcpHandle)= FALSE) TCP CLOSE tcpHandle NEXT ix
Code:
tcpHandle = FREEFILE TCP OPEN PORT 6713 AT "127.0.0.1" AS tcpHandle TIMEOUT 5000 FOR ix = 1 TO 10 TCP SEND tcpHandle, dataIn DO TCP RECV tcpHandle, 4096, Buffer$ dataOut = dataOut + Buffer$ LOOP WHILE (LEN(Buffer$)<>0) AND (EOF(tcpHandle)= FALSE) NEXT ix TCP CLOSE tcpHandle
My dataOut is a lot shorter than 4096 – so the code in the receive loop is executed only once.
Seems so simple - but I can not make it work. So, what is my mistake? Maybe impossible to do with TCP/IP?
Thanks!
Comment