'\"macro stdmacro .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)bind.2 6.6 (Berkeley) 5/22/86 .\" .if n .pH man2.bind @(#)bind 30.3 of 2/1/86 .TH BIND 2 .UC 5 .SH NAME bind \- bind a name to a socket .SH SYNOPSIS .B #include .br .B #include .sp .B "int bind (int s, const struct sockaddr \(**name, int namelen);" .SH DESCRIPTION .I Bind assigns a name to an unnamed socket. When a socket is created with .IR socket (2) it exists in a name space (address family) but has no name assigned. .I Bind requests that .IR name be assigned to the socket. .PP The rules used in name binding vary between communication domains. Consult the protocol manual entries in section 7 for detailed information. .SH "RETURN VALUE If the bind is successful, a 0 value is returned. A return value of \-1 indicates an error, which is further specified in the global \f2errno\fP. .SH ERRORS The \f2bind\fP call will fail if: .TP 20 [EBADF] \f2S\fP is not a valid descriptor. .TP 20 [ENOTSOCK] \f2S\fP is not a socket. .TP 20 [EADDRNOTAVAIL] The specified address is not available from the local machine. .TP 20 [EADDRINUSE] The specified address is already in use. .TP 20 [EINVAL] The socket is already bound to an address. .TP 20 [EACCES] The requested address is protected, and the current user has inadequate permission to access it. .TP 20 [EFAULT] The \f2name\fP parameter is not in a valid part of the user address space. .P See also the protocol-specific manual pages for other error values. .SH SEE ALSO connect(2), listen(2), socket(2), tcp(7P), udp(7P), unix(7F) .SH NOTE ABI-compliant versions of the above call can be obtained from .IR libsocket.so . '\".so /pubs/tools/origin.bsd