Windows Sockets error code

xiaoxiao2021-03-06  70

Appendix A Windows Sockets Errors

Windows Sockets defines all error codes in header file Winsock.H, including the error code returned by the Windows Sockets that is headed by the "WSA" and the error code defined by Berkeley Sockets. Defining the Berkeley Sockets error code is to ensure the portability of the original software.

A.1 Windows Sockets error code list

Table A.1 lists the possible error codes returned by the wsagetlasterror () function and their explanation, which can be divided into four parts.

The first part of the error code is used to solve inconsistent definitions of the standard C error code in different C compilation. The second part of the error code is the Windows Sockets version of the standard Berkeley Sockets error code. The third part of the error code includes an error code for a specific Windows sockets expansion. The fourth part of the error code is returned by the getxby () and wsaasyncgetxby () functions of Windows sockets, which is equivalent to the error returned by the variable h_errno in the Berkeley software (in fact, Windows Sockets have defined H_Error in the header file Winsock.h. A macro for WSageTlasteError (), which is equivalent to various failures returned by domain name service. If the Windows Sockets implementation does not use a domain name service, it will use the most appropriate code. In general, the Windows Sockets application should interpret errors WSAHOST_NOT_FOUND and WSANO_DATA to indicate that keywords (name, address, etc.) are not found, and erroneous WSATRY_AGAIN and WSANO_RECOVERY are reminded that the name service itself is not operated.

The error code is defined by the Windows Sockets specification, which is consistent in all Windows Sockets compatible implementations of all the same version specification.

Table A.1 Windows Sockets error code

Windows Sockets error code

Berkeley corresponds to error code

Wrong number

Explanation

WSAEINTR

Eintr

10004

Tong standard C

WSAEBADF

Ebadf

10009

Tong standard C

Wsaeacces

Eacces

10013

Tong standard C

WSAEFAULT

Efault

10014

Tong standard C

WSAEINVAL

Einval

10022

Tong standard C

WSaemfile

Emfile

10024

Tong standard C

WSAEWOULDBLOCK

Ewouldblock

10035

BSD

WSAEINPROGRESS

EinProgress

10036

When a blocking function is in progress, call any Windows Sockets API function returns this error.

WSAEAALReady

Ealready

10037

BSD

WSAENOTSOCK

ENOTSOCK

10038

BSD

WSAEDESTADDRREQ

EDESTADDRREQ

10039

BSD

WSaemSgsize

EMSGSIZE

10040

BSD

WSAEPROTYPE

EPROTOTYPE

10041

BSD

Wsaenoprotoopt

Enoprotoopt

10042

BSD

WSAEPROTONOSUPPORT

EPROTONOSUPPORT

10043

BSD

WSAESOCKTNOSUPPORT

EsockTnosupport

10044

BSD

WSAEOPNOTSUPP

EopNotsupp

10045

BSD

WSAEPFNOSupport

EPFNOSUPPORT

10046

BSD

WSAEafnosupport

Eafnosupport10047

BSD

WSAEADDRINUSE

EADDRINUSE

10048

BSD

WSAEADDRNOTAVAIL

EADDRNOTAVAIL

10049

BSD

WSAenetdown

ENetdown

10050

With BSD. This error is reported to this error whenever the Windows Sockets failed to detect the network subsystem.

WSAENETUNREACH

ENetunreach

10051

BSD

WSAENETRESet

EnetReset

10052

BSD

Wsaeconnaborted

Econnaborted

10053

BSD

WSaeconnreset

Econnreset

10054

BSD

WSAenobufs

Enobufs

10055

BSD

WSAEisconn

Eisconn

10056

BSD

WSAENOTCONN

ENOTCONN

10057

BSD

WSAESHUTDOWN

ESHUTDOWN

10058

BSD

WSaetoomanyrefs

ETOOMANYREFS

10059

BSD

WSaetimedout

ETIMEDOUT

10060

BSD

WSAEConnrefused

Econnrefused

10061

BSD

WSAELOOP

ELOOP

10062

BSD

Wsaenametoolong

Enametoolong

10063

BSD

WSAEHOSTDOWN

EhostDown

10064

BSD

WSAEHOSTUNREACH

Ehostunreach

10065

BSD

WSASYSNOTREADY

10091

Returns from WSAStartup () indicating that the network subsystem cannot be used.

WSAVERNOTSUPPORTED

10092

Returns WSAStartup (), indicating that Windows SocketSdll cannot support this application.

WSANotinitialiad

10093

Returns the other functions other than WSAStartup (), indicating that there is no successful WSAStartup () call execution.

WSaediscon

10101

Returns WSAARECV () and WSARECVFROM () indicating that the remote side has initialized a "elegant" Shutdown sequence.

WSAHOST_NOT_FOND

HOST_NOT_FOND

11001

BSD

WSATRY_AGAIN

TRY_AGAIN

11002

BSD

WSANO_RECOVERY

NO_RECOVERY

11003

BSD

WSANO_DATA

NO_DATA

11004

BSD

A.2 Windows Sockets error code extension description

The possible error code returned by the WsageTlasterror () function is given in alphabetical order, and a brief extension description is given.

WSAEAcces (10013) Permission Denied.

Try to access the socket using the forbidden access. For example, use a function sendTo () to send data to a broadcast address on the socket of the broadcast privilege () without using the SO_Broadcast command that uses the function setsockopt ().

WSAEADDRINUSE (10048) Address Already in Use.

Under normal circumstances, each socket address (protocol / IP address / port number) is only allowed once. This error occurs when the application tries to use the bind () function to bring an IP address / port number that is already existing or unsatuted with or off-closing socket to a new socket. For server applications, if you need to use a bind () function to bring multiple sockets to the same port, you can consider the SO_REUSEADDR command for using the setsockopt () function. Customer applications generally do not have to use a bind () function --connect () function always automatically selects the port number that is not used. When the bind () function is a wildcard address (including addr_any), error WSAEADDRINUSE may be delayed to a clear address being submitted. This may occur during subsequent functions such as connect (), listen (), wsaconnect () or wsajoinleaf (). WSAEADDRNOTAVAIL (10049) Cannot Assign Requested Address.

The requested address is illegal in its environment. Usually attempts to tighten an unauthorized address of a local machine to the socket to the socket. It may also be generated when connect (), sendto (), wsaconnect (), wsajoinleaf () or wsasendto () function is generated due to remote machines or port numbers (such as 0 address or 0 port number).

WSAEAFNOSUPPORT (10047) Address Family Not Supported by Protocol Family.

The address used is incompatible with the requested protocol. All sockets are linked to an address family (AF_INET corresponding to the IP protocol) and a common protocol type (such as Sock_Stream). If an incorrect protocol is explicitly requested in the socket () call, the error is used to use the address of the address family that is incorrectly in the socket, which is used to return.

WSAEAALREADY (10037) Operation Already in Progress.

When there is an operation on the non-block socket already in progress, another operation attempts to execute this error is generated. Such as: On a non-block socket that is performing a connection, call the connect () function; or cancel a asynchronous request that has been canceled or completed (WSaAsyncGetxByy ()).

Wsaeconnaborted (10053) Software Caused Connection Abort.

A established connection is terminated by the software on your host, probably because of a data transfer timeout or an agreement error.

WSAEConnrefused (10061) Connection Refused.

Because the target host actively refuses, the connection cannot be established. This is usually because it is trying to connect to a remote host that is not active on a remote host, such as no server application is executing.

WSAECONNRESET (10054) Connection Reset by Peer.

The existing connection is mandated by a remote host. Usually, the remote host is suddenly stopped, or the remote host is restarted, or the remote host uses "Forced" on the remote square connector (see SetsockOpt (SO_Linger). In addition, when one or more operations are being processed, if the connection detects a failure due to the "Keep-Alive" activity, this error may also cause this error. At this time, the ongoing operation is returned by the error code WSAENETRESET failed, and the subsequent operation returns the error code WSAECONNRESET. WSAEDESTADDRRRRRRRRRRRRREQ (10039) Destination Address Required.

The address that must be in the socket is missing. For example, this error is returned if the sendto () function is called and the remote address is addr_any.

WSAEFAULT (10014) Bad Address.

The system detects that a pointer parameter attempts to use is a illegal pointer address. If the application passes an illegal pointer value, or the buffer length is too small, this error occurs. For example, the parameter is structured SockAddr, but the length of the parameter is less than SizeOf (Struct SockAddr).

WSAEHOSTDOWN (10064) Host is Down.

Socket operation fails because the destination host is turned off. Socket operation encounters unactivated hosts. The network activity on the local host is not initialized. These conditions are more appropriate by the error code WSAetimedout indication.

WSAEHOSTUNREACH (10065) No Route to Host.

Try to make a socket operation with an unreachable host. See WSAENETUNREACH.

WSAEINPROGRESS (10036) Operation Now in Progress.

A blocking operation is being executed. Windows Sockets only allows a task (or thread) to have an unfinished blocking operation at the same time, if any function is called (regardless of whether this function is referenced to the socket or any other socket), this function Will return with error code WSAEINPROGRESS.

WSAEINTR (10004) Interrupted Function Call.

Blocking operation is interrupted by the function wsacancelblockingcall () call.

WSAEINVAL (10022) Invalid Argument.

Illegal parameters are provided (for example, the illegal levels are specified when using the setsockopt () function. In some instances, it may also be related to the current state of the socket, for example, call the Accept () function when the socket does not use listen () to in listening.

WSAEisconn (10056) Socket is already connected.

The connection request occurs on the socket already connected. Some implementations return this error for the case where the SOCK_DGRAM socket is used on the SOCK_DGRAM socket (for the Sock_Stream socket, the SENDTO () function is ignored), although other implementations treat this operation as legal event.

WSAEMFILE (10024) Too Many Open Files. Open too much socket. Whether it is for the entire system or every process or thread, Windows Sockets implementation may have a maximum number of socket literals.

WSaemsgsize (10040) Message Too Long.

One message sent on the data settlement is greater than the internal message buffer or some other network restrictions, or the buffer used to accept the datagram is smaller than the diverbed itself.

WSAENETDOWN (10050) Network is down.

Socket operation encounters an inactive network. This error may indicate a network system (such as the protocol stack running in Winsock DLL), a network interface or the local network itself has a serious failure.

WSAENETRESET (10052) Network Dropped Connection On Reset.

The connection is interrupted when the operation is being processed because "Keep-alive" is detected. It may also be returned by the setsockopt () function, if you try to use it on a failed connection to set SO_keepalive.

WSAENETUNREACH (10051) NetWork is unreachable.

Try to make a socket operation with a network that cannot be reached. It often means that local software does not know the route to the remote host.

WSAenobufs (10055) No Buffer Space Available.

Since the system lacks sufficient buffer space, or because the queue is full, the operation on the socket cannot be executed.

WSAENOPROTOOPT (10042) Bad Protocol Option.

In GetSockOpt () or setsockopt () call, you specify an unknown, illegal or unsupported option or layer (Level).

WSAENOTCONN (10057) Socket is not connection.

Because the socket is not connected, the request is sent or received is not allowed, or the address is not provided when the sendTO () function is transmitted on the data settlement. Any other type of operation can also return this error, for example, using the setsockopt () function sets SO_keepalive on a reset connection.

WSAENOTSOCK (10038) Socket Operation on Non-Socket.

Operation is not on the socket. It may be that the socket handle parameter is not referenced to a legitimate socket, or when calling the select () function, the member in an FD_set is not legal.

WSAEOPNOTSUPP (10045) Operation Not Supported.

For the type of the referenced object, the operation attempting to do is not supported. Usually it occurs on a socket descriptor that does not support this operation, for example, attempts to receive connections on the data setup.

WSAEPFNOSupport (10046) Protocol Family Not Supported.

The protocol cluster is not configured in the system or does not support its implementation. It is slightly different from WSAeafnosupport, but in most cases, it is a description of all Windows Sockets functions that return these two errors. Description of WSAEafnosupport. WSAEPROCLIM (10067) TOO MANY Processes.

Windows Sockets implementation may limit the number of applications using it, if this restriction is reached, the WSAStartup () function may fail to fail.

WSAEPROTONOSUPPORT (10043) Protocol Not Supported.

The requested protocol is not configured in the system or does not support its implementation. For example, a socket () call requests a SOCK_DGRAM socket, but specified is a streaming protocol.

WSAEPROTYPE (10041) Protocol WRONG TYPE for Socket.

The protocol specified in the socket () function call does not support the semantics of the requested socket type. For example, the ARPA INTERNET UDP protocol cannot be specified with the SOCK_STREAM socket type.

WSAESHUTDOWN (10058) Cannot Send After Socket Shutdown.

Since the socket has been turned off in the corresponding direction in the respective direction, the transmission or reception request in this direction is not allowed. By calling the shutdown () function requesting the portion of the socket to close, it sends a signal to stop sending or receiving or two-way operations.

WSAESOCKTNOSUPPORT (10044) Socket Type Not Supported.

Socket types specified in this address family are not supported. For example, an optional socket type SOCK_RAW is selected in the Socket () call, but the implementation does not support the socket_raw type of sockets at all.

WSaetimedout (10060) Connection Timed Out.

Connection requests fail to fail to respond correctly within a time period, or the established connections fail due to the connected hosts that cannot be responded.

WSATYPE_NOT_FOUND (10109) Class Type Not Found

The specified class is not found.

WSAEWOULDBLOCK (10035) Resource Temporarily Unavailable.

This error is returned by the operation that cannot be completed immediately on the non-block socket, for example, the RECV () function is called when the socket is not queued. This error is not a serious error, and the corresponding operation should be retryed later. Reporting WSaewoldBlock is normal for the NBCT () function, which is required to take some time for establishing a connection.

WSAHOST_NOT_FOUND (11001) Host Not Found.

The host is unknown. This name is not a formal host name, nor an alias, which cannot be found in the query database. This error may also be returned in the protocol and service query, which means that the specified name cannot be found in the relevant database.

WSA_INVALID_HANDE (OS Dependent) Specified Event Object Handle Is Invalid.

The application tries to use an event object, but the specified handle is illegal.

WSA_INVALID_PARAMETER (OS Dependent) One or More Parameters Are Invalid. The application uses a WINSOCK function that maps to the Win32 function, while the Win32 function indicates that one or more parameters have problems.

WSAINVALIDPROCTABLE (OS Dependent) Invalid Procedure Table from Service Provider.

The service provider returns a fake WS2_32.dll program (Procedure) table. This is usually caused by one or more function pointers.

WSAINVALIDPROVIDER (OS Dependent) Invalid Service Provider Version Number.

The service provider returns a version number different from 2.2.

WSA_IO_INCOMPLETE (OS Dependent) Overlapped I / O Event Object Not in Signaled State.

The application attempts to detect a state in which no overlap operation is completed. The application uses a function wsagetoverlappedResult () (parameter fwait set to false) to get this error code when the overlapping operation is completed, unless the operation is complete.

WSA_IO_PENDING (OS Dependent) Overlapped Operations Will Complete Later.

The application has initialized an overlapping operation that cannot be completed immediately. When this operation is completed later, there will be a completion indication.

WSA_NOT_ENOUGH_MEMORY (OS Dependent) Insufficient Memory Available.

The application uses a WINSOCK function that maps to Win32 functions, while the Win32 function indicates the lack of necessary memory resources.

WSANotInitialiad (10093) Successful WSAStartup () Not yet performed.

The application does not call the wsastartup () function, or the function wsastartup () call failed. Applications may access sockets that do not belong to the current active task (for example, trying to build a shared socket between tasks), or call too much wsacleanup () function.

WSANO_DATA (11004) Valid Name, No Data Record of Requested Type.

The requested name is legal and found in the database, but it does not have the correct correlation data for parsing. The normal example of this error is the host name-to-address (using a gethostByname () or wsaasyncgetHostByName () function, returns MX (Mail Exchange) record but does not have a (address) record, it indicates that the host itself exists. But you can't arrive directly.

WSANO_RECOVERY (11003) this is a non-recoverable error.

This error code indicates that some kind of unrecoverable error occurs during database findings. It may be due to database files (such as BSD-compatible hosts, services, or protocols files) that cannot be found, or DNS requests should be returned.

WSAPROVIDERFAILEDINIT (OS Dependent) Unable to Initialize a Service Provider.

The service provider's DLL cannot load (LoadLibrary () failed) or the provider's Wspstartup / NspStartup function failed. WSASYSCALLFAILURE (OS Dependent) System Call Failure ..

Returns when a system call that should not fail fails. For example, if WaitFormultiPleObjects () call fails, or registered APIs cannot take advantage of protocol / name space directory.

WSASYSNOTREADY (10091) Network subsystem is unavailable.

This error is returned by the WSAStartup () function, indicating that the Windows Sockets implementation is unavailable because the underlying system is used to provide network services. Users should check:

Is there a suitable Windows Sockets DLL file in the current path.

Do you use multiple Winsock implementations at the same time. If there are more than one Winsock DLL in the system, you must ensure that the first Winsock DLL file in the search path is required to be currently loaded.

View the document implemented by Winsock to make sure all necessary parts are properly installed and configured.

WSATRY_AGAIN (11002) Non-Authoritative Host Not Found.

This error is usually a temporary error when the hostname is parsed, which means that the local server does not receive a response from the authorization server. The retry will be successful later.

WsaverNotsupported (10092) Winsock.dll Version Out of Range.

The current Winsock implementation does not support the application specified by the application. Check if an old Windows Sockets DLL file is being accessed.

WSAEDISCON (10101) Graceful Shutdown in Progress.

Returns the wsarecv () and wsarecvfrom () functions, indicating that the remote side has initialized a "elegant" closed sequence.

WSA_OPERATION_ABORTED (OS Dependent) Overlapped Operation Aborted.

Because the closure of the socket, a overlapping operation is canceled, or the SIO_FLUSH command for the WSAIOCTL () function is executed.

转载请注明原文地址:https://www.9cbs.com/read-111583.html

New Post(0)