Bind a name to a socket
#include <sys/types.h> #include <sys/socket.h> int bind( int s, const struct sockaddr * name, socklen_t namelen );
- The file descriptor to be bound.
- A pointer to the sockaddr structure that holds the address to be bound to the socket. The socket length and format depend upon its address family.
- The length of the sockaddr structure pointed to by name.
Use the -l socket option to qcc to link against this library.
When a socket is created with socket(), it exists in a namespace (address family) but has no name assigned to it. The bind() function assigns a name to that unnamed socket.
The bind() function assigns a local address. Use connect() to assign a remote address.
The rules used for binding names vary between communication domains.
Before calling bind() on an AF_INET socket, set the af_family member of the sockaddr structure to AF_INET.
- An error occurred ( errno is set).
- The requested address is protected, and the current user has inadequate permission to access it.
- The specified address is already in use.
- The specified address isn't available from the local machine.
- Invalid descriptor s.
- The name parameter isn't in a valid part of the user address space.
- The socket is already bound to an address.
- The given file descriptor isn't for a socket.
Last modified: 2014-06-24