TCP/IP for DOS Socket Library Reference
Appendix C. Socket Error Codes
This appendix lists and explains error codes that are returned if a socket function is unsuccessful.
Most socket library functions, if unsuccessful, store an error code in a variable to report the results of a function call. Application programs, therefore, can make error-handling decisions based on this value. Programs that use the DOS socket library can access these global variables directly. Programs that use the Windows socket library can use the appropriate function (GetErmo(), GetHErmo(), or GetDNSErmo()) to access the values maintained in the Windows DLL. Header files define names for these error codes. The application program should refer to those names, instead of the actual numerical values.
Table C-l lists in numerical order the socket library error codes stored in the variable errno and explains their meanings. These symbolic constants are defined in SOCKET.H.
Table C-1. Socket Library Error Codes
Table C-2 lists in numerical order the transport database function error codes stored in the h_errno variable and explains their meanings. These
symbolic constants are defined in SOCKET.H.
Code
Label
Explanation 9
EBADF
Bad socket number, probably because the socket() function has not yet been called and the specified
socket does not yet exist. 22
EINVAL
The request contained an invalid argument. 35
EWOULDBLOCK
The socket is synchronous nonblocking and no connection is established yet or no bytes were available
to be read. Retry the request. 36
EINPROGRESS
Operation now in progress; try the request again. With a close request, the socket will eventually be
closed so no further action is required. 37
EALREADY
The operation is currently in progress. 41
EPROTOTYPE
Protocol is the wrong type for the socket. 42
ENOPROTOOPT
Protocol is not available. 43
ENOPROTONOSUPPORT
The protocol type is not supported. 45
EOPNOTSUPP
The operation is not supported on the socket. Connectionless socket types, such as SOCK_DGRAM,
never support this operation. Only passive SOCK_STREAM sockets support this operation. 46
EPFNOSUPPORT
The protocol family is not supported. 47
EAFNOSUPPORT
Addresses in the specified address family cannot be used with this socket. 48
EADDRINUSE
An attempt was made to create a socket with a port that is already being used, or a connection already
exists on the same socket pair. 53
ECONNABORTED
A connection was aborted before it could be accepted. 54
ECONNRESET
The other end has aborted the connection to this SOCK_STREAM socket. Close the socket. 55
ENOBUFS
No buffer space is available, and the socket cannot be created. 56
EISCONN
The socket is already connected. This is not necessarily an error if the socket is synchronous
nonblocking, because it can indicate a successful connection request. 57
ENOTCONN
For a SOCK_STREAM socket, a connection has not yet been established, and therefore the socket is
not ready for data. 58
ESHUTDOWN
Cannot send data after socket is closed. 60
ETIMEOUT
An attempt to establish a connection timed out without establishing a connection. This error typically
occurs with TCP when IP communications with the peer system do not work. This failure can be
caused by anything from a broken cable to an IP address mismatch. Close the socket. 61
ECONNREFUSED
An attempt to establish a connection was rejected. This error typically occurs with TCP when no
passive open on the address is pending on the peer system. 66
ENOTINSTLD
The requested protocol is not installed. 67
EASYNCNOTSUPP
The requested asynchronous operation cannot be performed. This error occurs when standard DOS
applications run under Windows or DESQview and request asynchronous services. 68
ESYNCNOTSUPP
The requested synchronous function cannot be called from within an asynchronous function. 69
ENO_RCB
The socket library has run out of internal resources because there are too many outstanding socket
function calls.
Table C-2. Database Functions Error Codes
Table C-3 lists in numerical order the name resolution function error codes stored in the dns_errno variable and explains their meanings. These
symbolic constants are defined in SOCKET.H.
Code
Error
Explanation 1
HOST_NOT_FOUND
No such host exists in any HOSTS file in the search path defined by the PATH setting of the Protocol
TCPIP section in the NET.CFG file. 2
TRY_AGAIN
The name or address could not be resolved at the time of the request because of internal factors.
Another attempt to resolve the name may be successful. 3
NO_RECOVERY
This is a nonrecoverable error. 4
NO_ADDRESS
The host listed is in a HOSTS file but the address is missing or invalid.
Table C-3. Name Resolution Error Codes
Code
Error
Explanation 1
FILE_NOT_FOUND
The RESOLV.CFG file does not exist in any directory in the search path defined by the PATH setting
of the Protocol TCPIP section in the NET.CFG file. This error does not indicate a corrupted file. 2
NS_NOT_RESPONDING
The network name server(s) did not respond to a message.