Used to listen for incoming connections attempt on a socket. This function indicates that the program will listen for incoming connections on a socket.
SOCKET accept( _In_ SOCKET s, _Out_ struct sockaddr *addr, _Inout_ int *addrlen );
- s [in]
- A descriptor that identifies a socket that has been placed in a listening state with the listen function. The connection is actually made with the socket that is returned by accept.
- addr [out]
- An optional pointer to a buffer that receives the address of the connecting entity, as known to the communications layer. The exact format of the addr parameter is determined by the address family that was established when the socket from the sockaddr structure was created.
- addrlen [in, out]
- An optional pointer to an integer that contains the length of structure pointed to by the addr parameter.
If no error occurs, accept returns a value of type SOCKET that is a descriptor for the new socket. This returned value is a handle for the socket on which the actual connection is made.
Otherwise, a value of INVALID_SOCKET is returned, and a specific error code can be retrieved by calling WSAGetLastError.
The integer referred to by addrlen initially contains the amount of space pointed to by addr. On return it will contain the actual length in bytes of the address returned.
|WSANOTINITIALISED||A successful WSAStartup call must occur before using this function.|
|WSAECONNRESET||An incoming connection was indicated, but was subsequently terminated by the remote peer prior to accepting the call.|
|WSAEFAULT||The addrlen parameter is too small or addr is not a valid part of the user address space.|
|WSAEINTR||A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall.|
|WSAEINVAL||The listen function was not invoked prior to accept.|
|WSAEINPROGRESS||A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.|
|WSAEMFILE||The queue is nonempty upon entry to accept and there are no descriptors available.|
|WSAENETDOWN||The network subsystem has failed.|
|WSAENOBUFS||No buffer space is available.|
|WSAENOTSOCK||The descriptor is not a socket.|
|WSAEOPNOTSUPP||The referenced socket is not a type that supports connection-oriented service.|
|WSAEWOULDBLOCK||The socket is marked as nonblocking and no connections are present to be accepted.|