Bind
Description
Used to associate a local address to a socket in order to listen for incoming connections.
Could indicate sniffing capabilities.
Syntax
int bind(
_In_ SOCKET s,
_In_ const struct sockaddr *name,
_In_ int namelen
);
Parameters
- s [in]
- A descriptor identifying an unbound socket.
- name [in]
- A pointer to a sockaddr structure of the local address to assign to the bound socket .
- namelen [in]
- The length, in bytes, of the value pointed to by the name parameter.
Return value
If no error occurs, bind returns zero. Otherwise, it returns SOCKET_ERROR, and a specific error code can be retrieved by calling WSAGetLastError.
Error code | Meaning |
---|---|
WSANOTINITIALISED |
Note A successful WSAStartup call must occur before using this function. |
WSAENETDOWN | The network subsystem has failed. |
WSAEACCES |
An attempt was made to access a socket in a way forbidden by its access permissions. This error is returned if nn attempt to bind a datagram socket to the broadcast address failed because the setsockopt option SO_BROADCAST is not enabled. |
WSAEADDRINUSE |
Only one usage of each socket address (protocol/network address/port) is normally permitted. This error is returned if a process on the computer is already bound to the same fully qualified address and the socket has not been marked to allow address reuse with SO_REUSEADDR. For example, the IP address and port specified in the name parameter are already bound to another socket being used by another application. For more information, see the SO_REUSEADDR socket option in the SOL_SOCKET Socket Options reference, Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE, and SO_EXCLUSIVEADDRUSE. |
WSAEADDRNOTAVAIL |
The requested address is not valid in its context. This error is returned if the specified address pointed to by the name parameter is not a valid local IP address on this computer. |
WSAEFAULT |
The system detected an invalid pointer address in attempting to use a pointer argument in a call. This error is returned if the name parameter is NULL, the name or namelen parameter is not a valid part of the user address space, the namelen parameter is too small, the name parameter contains an incorrect address format for the associated address family, or the first two bytes of the memory block specified by name do not match the address family associated with the socket descriptor s. |
WSAEINPROGRESS | A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. |
WSAEINVAL |
An invalid argument was supplied. This error is returned of the socket s is already bound to an address. |
WSAENOBUFS |
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. This error is returned of not enough buffers are available or there are too many connections. |
WSAENOTSOCK |
An operation was attempted on something that is not a socket. This error is returned if the descriptor in the s parameter is not a socket. |