[Migrated content. Thread originally posted on 12 February 2010]
I need some help with C$SOCKET. The documentation states "If length = 0, then the return value is the number of bytes available to be read on the socket.". This doesn't seem to be working.The problem is that I need to be able to check the buffer to see how many bytes of data are ready for reading because I never know exactly how many bytes I will get. The system that I'm attempting to communicate with can vary from 2 to 1313 bytes of data in the buffer. I can set a timeval to time out, but that doesn't work with the 7.2 runtime.
Here is the section of code that I'm using and even though I know there is data in the receive buffer, RETURN-CODE always returns as zero.
MOVE 0 TO DATA-RCV-LENGTH
CALL "C$SOCKET" USING AGS-READ, SOCKET-HANDLE,
DATA-FROM-CLIENT, DATA-RCV-LENGTH
IF RETURN-CODE > 0
MOVE RETURN-CODE TO DATA-RCV-LENGTH
CALL "C$SOCKET" USING AGS-READ, SOCKET-HANDLE,
DATA-FROM-CLIENT, DATA-RCV-LENGTH
END-IF



