Highlighted
Absent Member.
Absent Member.
1615 views

[archive] Help!!! C$socket

[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
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Help!!! C$socket

I also have written several routines that use the C$Sockets and the first time I used it I also found this to not work at all... Fortunately the different projects we had surrounding these, in one we were controlling both ends so we knew exactly the length of the data. And in another instance we always had a closing tag (because the data was xml) so we read byte by byte until we found the closing tag. Maybe this is something you can do with your application...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Help!!! C$socket

I also have written several routines that use the C$Sockets and the first time I used it I also found this to not work at all... Fortunately the different projects we had surrounding these, in one we were controlling both ends so we knew exactly the length of the data. And in another instance we always had a closing tag (because the data was xml) so we read byte by byte until we found the closing tag. Maybe this is something you can do with your application...


Thanks, that is exactly what I'm doing at this point. The system I'm communicating with uses a communication protocol that is similar to 3780 in that they transmit a set of control codes for start of text and end of text, followed by a two byte CRC. So for the most part I can read to the end of text and know that the following two bytes are going to be the last two. Or if the control codes that start are ACK, NAK, EOT that it won't be followed by any more. The potential problem that I see though is that we could have a situation where the system stopped writing part way through the data stream and because I would never see a ETX I would hit the end of the data and hang waiting for more characters.

I placed a Support call for this problem, so hopefully they can come up with something. Worse case I can use the Windows API calls directly. I've been looking at the SDK information on the winsock commands and I think I can figure them out. It's just not as easy as using the C$SOCKET calls.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Help!!! C$socket

Bump... Anyone else have any ideas. It's been a month since I got a response that Tech support was looking into it. I'm sure glad we don't make our customers wait that long for a resolution. We wouldn't have any customers anymore.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.