Jump to content

WSA error to text


Cotino
 Share

Recommended Posts

Hi,

I was playing with TCP functions and noticed that if it failed it only gave the WSA error number without any additional info.
So I made this function that returns extended info about a WSA error number in an array.
Just input the WSA error code and get an array such as :
[0] error number
[1] error name
[2] error title
[3] error description

If the input isn't a number, return 0 and set error to 1
If the input couldn't be found, return 0 and set error to 2

Here's the function :

Func WSAerrorToText($error)

    If NOT IsNumber($error) Then Return SetError(2, 0, 0)

    Local $return[4] = [$error, "Unknown", "Unknown", "Unknown"]

    Switch $error

        Case 6
            $return[1] = "WSA_INVALID_HANDLE"
            $return[2] = "Specified event object handle is invalid"
            $return[3] = "An application attempts to use an event object, but the specified handle is not valid. Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 8
            $return[1] = "WSA_NOT_ENOUGH_MEMORY"
            $return[2] = "Insufficient memory available"
            $return[3] = "An application used a Windows Sockets function that directly maps to a Windows function. The Windows function is indicating a lack of required memory resources. Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 87
            $return[1] = "WSA_INVALID_PARAMETER"
            $return[2] = "One or more parameters are invalid"
            $return[3] = "An application used a Windows Sockets function which directly maps to a Windows function. The Windows function is indicating a problem with one or more parameters. Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 995
            $return[1] = "WSA_OPERATION_ABORTED"
            $return[2] = "Overlapped operation aborted"
            $return[3] = "An overlapped operation was canceled due to the closure of the socket, or the execution of the SIO_FLUSH command in [WSAIoctl](/windows/desktop/api/Winsock2/nf-winsock2-wsaioctl). Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 996
            $return[1] = "WSA_IO_INCOMPLETE"
            $return[2] = "Overlapped I/O event object not in signaled state"
            $return[3] = "The application has tried to determine the status of an overlapped operation which is not yet completed. Applications that use [WSAGetOverlappedResult](/windows/desktop/api/Winsock2/nf-winsock2-wsagetoverlappedresult) (with the fWait flag set to FALSE) in a polling mode to determine when an overlapped operation has completed, get this error code until the operation is complete. Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 997
            $return[1] = "WSA_IO_PENDING"
            $return[2] = "Overlapped operations will complete later"
            $return[3] = "The application has initiated an overlapped operation that cannot be completed immediately. A completion indication will be given later when the operation has been completed. Note that this error is returned by the operating system, so the error number may change in future releases of Windows."

        Case 10004
            $return[1] = "WSAEINTR"
            $return[2] = "Interrupted function call"
            $return[3] = "A blocking operation was interrupted by a call to [WSACancelBlockingCall](/windows/desktop/api/winsock2/nf-winsock2-wsacancelblockingcall)."

        Case 10009
            $return[1] = "WSAEBADF"
            $return[2] = "File handle is not valid"
            $return[3] = "The file handle supplied is not valid."

        Case 10013
            $return[1] = "WSAEACCES"
            $return[2] = "Permission denied"
            $return[3] = "An attempt was made to access a socket in a way forbidden by its access permissions. An example is using a broadcast address for [sendto](/windows/desktop/api/winsock/nf-winsock-sendto) without broadcast permission being set using [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt)(SO_BROADCAST). Another possible reason for the WSAEACCES error is that when the [bind](/windows/desktop/api/winsock/nf-winsock-bind) function is called (on Windows NT 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address with exclusive access. Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the [SO_EXCLUSIVEADDRUSE](so-exclusiveaddruse.md) option."

        Case 10014
            $return[1] = "WSAEFAULT"
            $return[2] = "Bad address"
            $return[3] = "The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a [sockaddr](sockaddr-2.md) structure, is smaller than the sizeof(sockaddr)."

        Case 10022
            $return[1] = "WSAEINVAL"
            $return[2] = "Invalid argument"
            $return[3] = "Some invalid argument was supplied (for example, specifying an invalid level to the [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) function). In some instances, it also refers to the current state of the socket—for instance, calling [accept](/windows/desktop/api/Winsock2/nf-winsock2-accept) on a socket that is not listening."

        Case 10024
            $return[1] = "WSAEMFILE"
            $return[2] = "Too many open files"
            $return[3] = "Too many open sockets. Each implementation may have a maximum number of socket handles available, either globally, per process, or per thread."

        Case 10035
            $return[1] = "WSAEWOULDBLOCK"
            $return[2] = "Resource temporarily unavailable"
            $return[3] = "This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example [recv](/windows/desktop/api/winsock/nf-winsock-recv) when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling [connect](/windows/desktop/api/Winsock2/nf-winsock2-connect) on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established."

        Case 10036
            $return[1] = "WSAEINPROGRESS"
            $return[2] = "Operation now in progress"
            $return[3] = "A blocking operation is currently executing. Windows Sockets only allows a single blocking operation—per- task or thread—to be outstanding, and if any other function call is made (whether or not it references that or any other socket) the function fails with the WSAEINPROGRESS error."

        Case 10037
            $return[1] = "WSAEALREADY"
            $return[2] = "Operation already in progress"
            $return[3] = "An operation was attempted on a nonblocking socket with an operation already in progress—that is, calling [connect](/windows/desktop/api/Winsock2/nf-winsock2-connect) a second time on a nonblocking socket that is already connecting, or canceling an asynchronous request (WSAAsyncGetXbyY) that has already been canceled or completed."

        Case 10038
            $return[1] = "WSAENOTSOCK"
            $return[2] = "Socket operation on nonsocket"
            $return[3] = "An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for [select](/windows/desktop/api/Winsock2/nf-winsock2-select), a member of an fd_set was not valid."

        Case 10039
            $return[1] = "WSAEDESTADDRREQ"
            $return[2] = "Destination address required"
            $return[3] = "A required address was omitted from an operation on a socket. For example, this error is returned if [sendto](/windows/desktop/api/winsock/nf-winsock-sendto) is called with the remote address of ADDR_ANY."

        Case 10040
            $return[1] = "WSAEMSGSIZE"
            $return[2] = "Message too long"
            $return[3] = "A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram was smaller than the datagram itself."

        Case 10041
            $return[1] = "WSAEPROTOTYPE"
            $return[2] = "Protocol wrong type for socket"
            $return[3] = "A protocol was specified in the [socket](/windows/desktop/api/Winsock2/nf-winsock2-socket) function call that does not support the semantics of the socket type requested. For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK_STREAM."

        Case 10042
            $return[1] = "WSAENOPROTOOPT"
            $return[2] = "Bad protocol option"
            $return[3] = "An unknown, invalid or unsupported option or level was specified in a [getsockopt](/windows/desktop/api/winsock/nf-winsock-getsockopt) or [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) call."

        Case 10043
            $return[1] = "WSAEPROTONOSUPPORT"
            $return[2] = "Protocol not supported"
            $return[3] = "The requested protocol has not been configured into the system, or no implementation for it exists. For example, a [socket](/windows/desktop/api/Winsock2/nf-winsock2-socket) call requests a SOCK_DGRAM socket, but specifies a stream protocol."

        Case 10044
            $return[1] = "WSAESOCKTNOSUPPORT"
            $return[2] = "Socket type not supported"
            $return[3] = "The support for the specified socket type does not exist in this address family. For example, the optional type SOCK_RAW might be selected in a [socket](/windows/desktop/api/Winsock2/nf-winsock2-socket) call, and the implementation does not support SOCK_RAW sockets at all."

        Case 10045
            $return[1] = "WSAEOPNOTSUPP"
            $return[2] = "Operation not supported"
            $return[3] = "The attempted operation is not supported for the type of object referenced. Usually this occurs when a socket descriptor to a socket that cannot support this operation is trying to accept a connection on a datagram socket."

        Case 10046
            $return[1] = "WSAEPFNOSUPPORT"
            $return[2] = "Protocol family not supported"
            $return[3] = "The protocol family has not been configured into the system or no implementation for it exists. This message has a slightly different meaning from WSAEAFNOSUPPORT. However, it is interchangeable in most cases, and all Windows Sockets functions that return one of these messages also specify WSAEAFNOSUPPORT."

        Case 10047
            $return[1] = "WSAEAFNOSUPPORT"
            $return[2] = "Address family not supported by protocol family"
            $return[3] = "An address incompatible with the requested protocol was used. All sockets are created with an associated address family (that is, AF_INET for Internet Protocols) and a generic protocol type (that is, SOCK_STREAM). This error is returned if an incorrect protocol is explicitly requested in the [socket](/windows/desktop/api/Winsock2/nf-winsock2-socket) call, or if an address of the wrong family is used for a socket, for example, in [sendto](/windows/desktop/api/winsock/nf-winsock-sendto)."

        Case 10048
            $return[1] = "WSAEADDRINUSE"
            $return[2] = "Address already in use"
            $return[3] = "Typically, only one usage of each socket address (protocol/IP address/port) is permitted. This error occurs if an application attempts to [bind](/windows/desktop/api/winsock/nf-winsock-bind) a socket to an IP address/port that has already been used for an existing socket, or a socket that was not closed properly, or one that is still in the process of closing. For server applications that need to bind multiple sockets to the same port number, consider using [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) (SO_REUSEADDR). Client applications usually need not call bind at all—[connect](/windows/desktop/api/Winsock2/nf-winsock2-connect) chooses an unused port automatically. When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed. This could happen with a call to another function later, including connect, [listen](/windows/desktop/api/Winsock2/nf-winsock2-listen), [WSAConnect](/windows/desktop/api/Winsock2/nf-winsock2-wsaconnect), or [WSAJoinLeaf](/windows/desktop/api/Winsock2/nf-winsock2-wsajoinleaf)."

        Case 10049
            $return[1] = "WSAEADDRNOTAVAIL"
            $return[2] = "Cannot assign requested address"
            $return[3] = "The requested address is not valid in its context. This normally results from an attempt to [bind](/windows/desktop/api/winsock/nf-winsock-bind) to an address that is not valid for the local computer. This can also result from [connect](/windows/desktop/api/Winsock2/nf-winsock2-connect), [sendto](/windows/desktop/api/winsock/nf-winsock-sendto), [WSAConnect](/windows/desktop/api/Winsock2/nf-winsock2-wsaconnect), [WSAJoinLeaf](/windows/desktop/api/Winsock2/nf-winsock2-wsajoinleaf), or [WSASendTo](/windows/desktop/api/Winsock2/nf-winsock2-wsasendto) when the remote address or port is not valid for a remote computer (for example, address or port 0)."

        Case 10050
            $return[1] = "WSAENETDOWN"
            $return[2] = "Network is down"
            $return[3] = "A socket operation encountered a dead network. This could indicate a serious failure of the network system (that is, the protocol stack that the Windows Sockets DLL runs over), the network interface, or the local network itself."

        Case 10051
            $return[1] = "WSAENETUNREACH"
            $return[2] = "Network is unreachable"
            $return[3] = "A socket operation was attempted to an unreachable network. This usually means the local software knows no route to reach the remote host."

        Case 10052
            $return[1] = "WSAENETRESET"
            $return[2] = "Network dropped connection on reset"
            $return[3] = "The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress. It can also be returned by [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) if an attempt is made to set [SO_KEEPALIVE](so-keepalive.md) on a connection that has already failed."

        Case 10053
            $return[1] = "WSAECONNABORTED"
            $return[2] = "Software caused connection abort"
            $return[3] = "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error."

        Case 10054
            $return[1] = "WSAECONNRESET"
            $return[2] = "Connection reset by peer"
            $return[3] = "An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET."

        Case 10055
            $return[1] = "WSAENOBUFS"
            $return[2] = "No buffer space available"
            $return[3] = "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."

        Case 10056
            $return[1] = "WSAEISCONN"
            $return[2] = "Socket is already connected"
            $return[3] = "A connect request was made on an already-connected socket. Some implementations also return this error if [sendto](/windows/desktop/api/winsock/nf-winsock-sendto) is called on a connected SOCK_DGRAM socket (for SOCK_STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence."

        Case 10057
            $return[1] = "WSAENOTCONN"
            $return[2] = "Socket is not connected"
            $return[3] = "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using [sendto](/windows/desktop/api/winsock/nf-winsock-sendto)) no address was supplied. Any other type of operation might also return this error—for example, [setsockopt](/windows/desktop/api/winsock/nf-winsock-setsockopt) setting [SO_KEEPALIVE](so-keepalive.md) if the connection has been reset."

        Case 10058
            $return[1] = "WSAESHUTDOWN"
            $return[2] = "Cannot send after socket shutdown"
            $return[3] = "A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous [shutdown](/windows/desktop/api/winsock/nf-winsock-shutdown) call. By calling shutdown a partial close of a socket is requested, which is a signal that sending or receiving, or both have been discontinued."

        Case 10059
            $return[1] = "WSAETOOMANYREFS"
            $return[2] = "Too many references"
            $return[3] = "Too many references to some kernel object."

        Case 10060
            $return[1] = "WSAETIMEDOUT"
            $return[2] = "Connection timed out"
            $return[3] = "A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond."

        Case 10061
            $return[1] = "WSAECONNREFUSED"
            $return[2] = "Connection refused"
            $return[3] = "No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running."

        Case 10062
            $return[1] = "WSAELOOP"
            $return[2] = "Cannot translate name"
            $return[3] = "Cannot translate a name."

        Case 10063
            $return[1] = "WSAENAMETOOLONG"
            $return[2] = "Name too long"
            $return[3] = "A name component or a name was too long."

        Case 10064
            $return[1] = "WSAEHOSTDOWN"
            $return[2] = "Host is down"
            $return[3] = "A socket operation failed because the destination host is down. A socket operation encountered a dead host. Networking activity on the local host has not been initiated. These conditions are more likely to be indicated by the error WSAETIMEDOUT."

        Case 10065
            $return[1] = "WSAEHOSTUNREACH"
            $return[2] = "No route to host"
            $return[3] = "A socket operation was attempted to an unreachable host. See WSAENETUNREACH."

        Case 10066
            $return[1] = "WSAENOTEMPTY"
            $return[2] = "Directory not empty"
            $return[3] = "Cannot remove a directory that is not empty."

        Case 10067
            $return[1] = "WSAEPROCLIM"
            $return[2] = "Too many processes"
            $return[3] = "A Windows Sockets implementation may have a limit on the number of applications that can use it simultaneously. [WSAStartup](/windows/desktop/api/winsock/nf-winsock-wsastartup) may fail with this error if the limit has been reached."

        Case 10068
            $return[1] = "WSAEUSERS"
            $return[2] = "User quota exceeded"
            $return[3] = "Ran out of user quota."

        Case 10069
            $return[1] = "WSAEDQUOT"
            $return[2] = "Disk quota exceeded"
            $return[3] = "Ran out of disk quota."

        Case 10070
            $return[1] = "WSAESTALE"
            $return[2] = "Stale file handle reference"
            $return[3] = "The file handle reference is no longer available."

        Case 10071
            $return[1] = "WSAEREMOTE"
            $return[2] = "Item is remote"
            $return[3] = "The item is not available locally."

        Case 10091
            $return[1] = "WSASYSNOTREADY"
            $return[2] = "Network subsystem is unavailable"
            $return[3] = "This error is returned by [WSAStartup](/windows/desktop/api/winsock/nf-winsock-wsastartup) if the Windows Sockets implementation cannot function at this time because the underlying system it uses to provide network services is currently unavailable. Users should check: " & @CRLF & "•That the appropriate Windows Sockets DLL file is in the current path." & @CRLF & "•That they are not trying to use more than one Windows Sockets implementation simultaneously. If there is more than one Winsock DLL on your system, be sure the first one in the path is appropriate for the network subsystem currently loaded." & @CRLF & "•The Windows Sockets implementation documentation to be sure all necessary components are currently installed and configured correctly."

        Case 10092
            $return[1] = "WSAVERNOTSUPPORTED"
            $return[2] = "Winsock"
            $return[3] = "dll version out of range.The current Windows Sockets implementation does not support the Windows Sockets specification version requested by the application. Check that no old Windows Sockets DLL files are being accessed."

        Case 10093
            $return[1] = "WSANOTINITIALISED"
            $return[2] = "Successful WSAStartup not yet performed"
            $return[3] = "Either the application has not called [WSAStartup](/windows/desktop/api/winsock/nf-winsock-wsastartup) or WSAStartup failed. The application may be accessing a socket that the current active task does not own (that is, trying to share a socket between tasks), or [WSACleanup](/windows/desktop/api/winsock/nf-winsock-wsacleanup) has been called too many times."

        Case 10101
            $return[1] = "WSAEDISCON"
            $return[2] = "Graceful shutdown in progress"
            $return[3] = "Returned by [WSARecv](/windows/desktop/api/Winsock2/nf-winsock2-wsarecv) and [WSARecvFrom](/windows/desktop/api/Winsock2/nf-winsock2-wsarecvfrom) to indicate that the remote party has initiated a graceful shutdown sequence."

        Case 10102
            $return[1] = "WSAENOMORE"
            $return[2] = "No more results"
            $return[3] = "No more results can be returned by the [WSALookupServiceNext](/windows/desktop/api/Winsock2/nf-winsock2-wsalookupservicenexta) function."

        Case 10103
            $return[1] = "WSAECANCELLED"
            $return[2] = "Call has been canceled"
            $return[3] = "A call to the [WSALookupServiceEnd](/windows/desktop/api/Winsock2/nf-winsock2-wsalookupserviceend) function was made while this call was still processing. The call has been canceled."

        Case 10104
            $return[1] = "WSAEINVALIDPROCTABLE"
            $return[2] = "Procedure call table is invalid"
            $return[3] = "The service provider procedure call table is invalid. A service provider returned a bogus procedure table to Ws2_32.dll. This is usually caused by one or more of the function pointers being NULL."

        Case 10105
            $return[1] = "WSAEINVALIDPROVIDER"
            $return[2] = "Service provider is invalid"
            $return[3] = "The requested service provider is invalid. This error is returned by the [WSCGetProviderInfo](/windows/desktop/api/Ws2spi/nf-ws2spi-wscgetproviderinfo) and [WSCGetProviderInfo32](/windows/desktop/api/Ws2spi/nf-ws2spi-wscgetproviderinfo32) functions if the protocol entry specified could not be found. This error is also returned if the service provider returned a version number other than 2.0."

        Case 10106
            $return[1] = "WSAEPROVIDERFAILEDINIT"
            $return[2] = "Service provider failed to initialize"
            $return[3] = "The requested service provider could not be loaded or initialized. This error is returned if either a service provider's DLL could not be loaded ([LoadLibrary](https://msdn.microsoft.com/en-us/library/ms684175(v=VS.85).aspx) failed) or the provider's [WSPStartup](/windows/desktop/api/Ws2spi/nf-ws2spi-wspstartup) or [NSPStartup](/windows/desktop/api/Ws2spi/nf-ws2spi-nspstartup) function failed."

        Case 10107
            $return[1] = "WSASYSCALLFAILURE"
            $return[2] = "System call failure"
            $return[3] = "A system call that should never fail has failed. This is a generic error code, returned under various conditions. Returned when a system call that should never fail does fail. For example, if a call to [WaitForMultipleEvents](/windows/desktop/api/Winsock2/nf-winsock2-wsawaitformultipleevents) fails or one of the registry functions fails trying to manipulate the protocol/namespace catalogs. Returned when a provider does not return SUCCESS and does not provide an extended error code. Can indicate a service provider implementation error."

        Case 10108
            $return[1] = "WSASERVICE_NOT_FOUND"
            $return[2] = "Service not found"
            $return[3] = "No such service is known. The service cannot be found in the specified name space."

        Case 10109
            $return[1] = "WSATYPE_NOT_FOUND"
            $return[2] = "Class type not found"
            $return[3] = "The specified class was not found."

        Case 10110
            $return[1] = "WSA_E_NO_MORE"
            $return[2] = "No more results"
            $return[3] = "No more results can be returned by the [WSALookupServiceNext](/windows/desktop/api/Winsock2/nf-winsock2-wsalookupservicenexta) function."

        Case 10111
            $return[1] = "WSA_E_CANCELLED"
            $return[2] = "Call was canceled"
            $return[3] = "A call to the [WSALookupServiceEnd](/windows/desktop/api/Winsock2/nf-winsock2-wsalookupserviceend) function was made while this call was still processing. The call has been canceled."

        Case 10112
            $return[1] = "WSAEREFUSED"
            $return[2] = "Database query was refused"
            $return[3] = "A database query failed because it was actively refused."

        Case 11001
            $return[1] = "WSAHOST_NOT_FOUND"
            $return[2] = "Host not found"
            $return[3] = "No such host is known. The name is not an official host name or alias, or it cannot be found in the database(s) being queried. This error may also be returned for protocol and service queries, and means that the specified name could not be found in the relevant database."

        Case 11002
            $return[1] = "WSATRY_AGAIN"
            $return[2] = "Nonauthoritative host not found"
            $return[3] = "This is usually a temporary error during host name resolution and means that the local server did not receive a response from an authoritative server. A retry at some time later may be successful."

        Case 11003
            $return[1] = "WSANO_RECOVERY"
            $return[2] = "This is a nonrecoverable error"
            $return[3] = "This indicates that some sort of nonrecoverable error occurred during a database lookup. This may be because the database files (for example, BSD-compatible HOSTS, SERVICES, or PROTOCOLS files) could not be found, or a DNS request was returned by the server with a severe error."

        Case 11004
            $return[1] = "WSANO_DATA"
            $return[2] = "Valid name, no data record of requested type"
            $return[3] = "The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. The usual example for this is a host name-to-address translation attempt (using [gethostbyname](/windows/desktop/api) or [WSAAsyncGetHostByName](/windows/desktop/api)) which uses the DNS (Domain Name Server). An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable."

        Case 11005
            $return[1] = "WSA_QOS_RECEIVERS"
            $return[2] = "QoS receivers"
            $return[3] = "At least one QoS reserve has arrived."

        Case 11006
            $return[1] = "WSA_QOS_SENDERS"
            $return[2] = "QoS senders"
            $return[3] = "At least one QoS send path has arrived."

        Case 11007
            $return[1] = "WSA_QOS_NO_SENDERS"
            $return[2] = "No QoS senders"
            $return[3] = "There are no QoS senders."

        Case 11008
            $return[1] = "WSA_QOS_NO_RECEIVERS"
            $return[2] = "QoS no receivers"
            $return[3] = "There are no QoS receivers."

        Case 11009
            $return[1] = "WSA_QOS_REQUEST_CONFIRMED"
            $return[2] = "QoS request confirmed"
            $return[3] = "The QoS reserve request has been confirmed."

        Case 11010
            $return[1] = "WSA_QOS_ADMISSION_FAILURE"
            $return[2] = "QoS admission error"
            $return[3] = "A QoS error occurred due to lack of resources."

        Case 11011
            $return[1] = "WSA_QOS_POLICY_FAILURE"
            $return[2] = "QoS policy failure"
            $return[3] = "The QoS request was rejected because the policy system couldn't allocate the requested resource within the existing policy."

        Case 11012
            $return[1] = "WSA_QOS_BAD_STYLE"
            $return[2] = "QoS bad style"
            $return[3] = "An unknown or conflicting QoS style was encountered."

        Case 11013
            $return[1] = "WSA_QOS_BAD_OBJECT"
            $return[2] = "QoS bad object"
            $return[3] = "A problem was encountered with some part of the filterspec or the provider-specific buffer in general."

        Case 11014
            $return[1] = "WSA_QOS_TRAFFIC_CTRL_ERROR"
            $return[2] = "QoS traffic control error"
            $return[3] = "An error with the underlying traffic control (TC) API as the generic QoS request was converted for local enforcement by the TC API. This could be due to an out of memory error or to an internal QoS provider error."

        Case 11015
            $return[1] = "WSA_QOS_GENERIC_ERROR"
            $return[2] = "QoS generic error"
            $return[3] = "A general QoS error."

        Case 11016
            $return[1] = "WSA_QOS_ESERVICETYPE"
            $return[2] = "QoS service type error"
            $return[3] = "An invalid or unrecognized service type was found in the QoS flowspec."

        Case 11017
            $return[1] = "WSA_QOS_EFLOWSPEC"
            $return[2] = "QoS flowspec error"
            $return[3] = "An invalid or inconsistent flowspec was found in the [QOS](https://msdn.microsoft.com/en-US/library/Aa374024(v=VS.80).aspx) structure."

        Case 11018
            $return[1] = "WSA_QOS_EPROVSPECBUF"
            $return[2] = "Invalid QoS provider buffer"
            $return[3] = "An invalid QoS provider-specific buffer."

        Case 11019
            $return[1] = "WSA_QOS_EFILTERSTYLE"
            $return[2] = "Invalid QoS filter style"
            $return[3] = "An invalid QoS filter style was used."

        Case 11020
            $return[1] = "WSA_QOS_EFILTERTYPE"
            $return[2] = "Invalid QoS filter type"
            $return[3] = "An invalid QoS filter type was used."

        Case 11021
            $return[1] = "WSA_QOS_EFILTERCOUNT"
            $return[2] = "Incorrect QoS filter count"
            $return[3] = "An incorrect number of QoS FILTERSPECs were specified in the FLOWDESCRIPTOR."

        Case 11022
            $return[1] = "WSA_QOS_EOBJLENGTH"
            $return[2] = "Invalid QoS object length"
            $return[3] = "An object with an invalid ObjectLength field was specified in the QoS provider-specific buffer."

        Case 11023
            $return[1] = "WSA_QOS_EFLOWCOUNT"
            $return[2] = "Incorrect QoS flow count"
            $return[3] = "An incorrect number of flow descriptors was specified in the QoS structure."

        Case 11024
            $return[1] = "WSA_QOS_EUNKOWNPSOBJ"
            $return[2] = "Unrecognized QoS object"
            $return[3] = "An unrecognized object was found in the QoS provider-specific buffer."

        Case 11025
            $return[1] = "WSA_QOS_EPOLICYOBJ"
            $return[2] = "Invalid QoS policy object"
            $return[3] = "An invalid policy object was found in the QoS provider-specific buffer."

        Case 11026
            $return[1] = "WSA_QOS_EFLOWDESC"
            $return[2] = "Invalid QoS flow descriptor"
            $return[3] = "An invalid QoS flow descriptor was found in the flow descriptor list."

        Case 11027
            $return[1] = "WSA_QOS_EPSFLOWSPEC"
            $return[2] = "Invalid QoS provider-specific flowspec"
            $return[3] = "An invalid or inconsistent flowspec was found in the QoS provider-specific buffer."

        Case 11028
            $return[1] = "WSA_QOS_EPSFILTERSPEC"
            $return[2] = "Invalid QoS provider-specific filterspec"
            $return[3] = "An invalid FILTERSPEC was found in the QoS provider-specific buffer."

        Case 11029
            $return[1] = "WSA_QOS_ESDMODEOBJ"
            $return[2] = "Invalid QoS shape discard mode object"
            $return[3] = "An invalid shape discard mode object was found in the QoS provider-specific buffer."

        Case 11030
            $return[1] = "WSA_QOS_ESHAPERATEOBJ"
            $return[2] = "Invalid QoS shaping rate object"
            $return[3] = "An invalid shaping rate object was found in the QoS provider-specific buffer."

        Case 11031
            $return[1] = "WSA_QOS_RESERVED_PETYPE"
            $return[2] = "Reserved policy QoS element type"
            $return[3] = "A reserved policy element was found in the QoS provider-specific buffer."

        Case Else
            SetError(1)

    EndSwitch

    Return $return

EndFunc

Example :

#include "WSAerrorToText.au3"

TCPStartup()
TCPConnect("127.0.0.1", 1)
If @error Then
    Local $WSAerror = WSAerrorToText(@error)
    MsgBox(0, $WSAerror[0] & " | " & $WSAerror[1], $WSAerror[2] & @CRLF & $WSAerror[3])
Else
    MsgBox(0, "", "No error")
EndIf
TCPShutdown()

 

Edited by Cotino
Link to comment
Share on other sites

Your example is an interesting function, would you be so kind and also show to us how to use this function ?

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 minute ago, Cotino said:

Why ? It would return an empty array.

I know, but it would not hurt. When coding, and not properly handling errors, returning the empty array, would save the script from a possible cash, as a array is expected.
You could even initialize the array as [$error, "not found", "not found", "not found"]. Is just a nice touch.

Thanks for sharing :)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...