You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to create a new device emulator for Hercules based on commadpt.c I am compiling under VMS but I believe the same issues exist on the major Hercules platforms. Like commadpt.c, I am calling write_socket() and read_socket(). My main reason for using these functions is that it seems to be implied that using send() / recv() or read() / write() directly would cause difficulties on one or other of the main platforms. Firstly, I wonder if this is really the case? Both sets of routines seem to work equally well on my platform. I wonder would send() and recv() be suitable for use on any and all platforms?
Secondly and more importantly, it appears that write_socket() and read_socket() only work correctly with blocking sockets. In the case of non-blocking sockets, such as in commadpt.c and in my code, write_socket() can end up writing some of the requested data to the network and returning -1 to indicate an error, with errno containing EWOULDBLOCK. The problem is that there is no indication of how much data was successfully written and how much was not, so there is no possibility of retrying the write later and getting it to work correctly. If the code is modified to always return the amount of data successfully written, the problem can be avoided and errors can still be detected by the caller examining errno if the returned value indicates the amount of data written was less than requested.
A similar issue exists with read_socket() but I have not been able to come up with a suitable fix as there is an added complication of detecting when the connection has been closed by the other end.
The text was updated successfully, but these errors were encountered:
I am attempting to create a new device emulator for Hercules based on commadpt.c I am compiling under VMS but I believe the same issues exist on the major Hercules platforms. Like commadpt.c, I am calling write_socket() and read_socket(). My main reason for using these functions is that it seems to be implied that using send() / recv() or read() / write() directly would cause difficulties on one or other of the main platforms. Firstly, I wonder if this is really the case? Both sets of routines seem to work equally well on my platform. I wonder would send() and recv() be suitable for use on any and all platforms?
Secondly and more importantly, it appears that write_socket() and read_socket() only work correctly with blocking sockets. In the case of non-blocking sockets, such as in commadpt.c and in my code, write_socket() can end up writing some of the requested data to the network and returning -1 to indicate an error, with errno containing EWOULDBLOCK. The problem is that there is no indication of how much data was successfully written and how much was not, so there is no possibility of retrying the write later and getting it to work correctly. If the code is modified to always return the amount of data successfully written, the problem can be avoided and errors can still be detected by the caller examining errno if the returned value indicates the amount of data written was less than requested.
A similar issue exists with read_socket() but I have not been able to come up with a suitable fix as there is an added complication of detecting when the connection has been closed by the other end.
The text was updated successfully, but these errors were encountered: