1
0
Files
irix-657m-src/eoe/man/man3n/bind.3n
2022-09-29 17:59:04 +03:00

133 lines
3.2 KiB
Plaintext

'\"macro stdmacro
.if n .pH g3n.bind @(#)bind 41.1 of 4/22/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} bind 3N "" "\&"
.if \nX=1 .ds x} bind 3N ""
.if \nX=2 .ds x} bind 3N "" "\&"
.if \nX=3 .ds x} bind "" "" "\&"
.TH \*(x}
.SH NAME
\f4bind\fP \- bind a name to a socket
.SH SYNOPSIS
.nf
.ft 4
#include <sys/types.h>
.LP
.ft 4
bind(int s, caddr_tr name, int namelen);
.fi
.SH DESCRIPTION
.LP
\f4bind\fP(\|)
assigns a name to an unnamed socket.
When a socket is created with \f4socket\f1(3N),
it exists in a name space (address family)
but has no name assigned.
\f4bind\fP(\|)
requests that the name pointed to by
.I name
be assigned to the socket.
.SH RETURN VALUE
.LP
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 \f4errno\f1.
.SH ERRORS
The
\f4bind\fP(\|)
call will fail if:
.TP 20
\f4EBADF\f1
.I s
is not a valid descriptor.
.TP
\f4ENOTSOCK\f1
.I s
is a descriptor for a file, not a socket.
.TP
\f4EADDRNOTAVAIL\f1
The specified address is not available on the local machine.
.TP
\f4EADDRINUSE\f1
The specified address is already in use.
.TP
\f4EINVAL\f1
.I namelen
is not the size of a valid address for the specified address family.
.TP
\f4EINVAL\f1
The socket is already bound to an address.
.TP
\f4EACCES\f1
The requested address is protected and the current user
has inadequate permission to access it.
.TP
\f4ENOSR\f1
There were insufficient
.SM STREAMS
resources for the operation to complete.
.LP
The following errors are specific to
binding names in the
.SM UNIX
domain:
.TP 20
\f4ENOTDIR\f1
A component of the path prefix of the pathname in
.I name
is not a directory.
.TP
\f4ENOENT\f1
A component of the path prefix of the pathname in
.I name
does not exist.
.TP
\f4EACCES\f1
Search permission is denied for a component of the path prefix of the
pathname in
.IR name .
.TP
\f4ELOOP\f1
Too many symbolic links were encountered in translating the pathname in
.IR name .
.TP
\f4EIO\f1
An I/O error occurred while making the directory entry or allocating the inode.
.TP
\f4EROFS\f1
The inode would reside on a read-only file system.
.TP
\f4EISDIR\f1
A null pathname was specified.
.SH SEE ALSO
.\".BR connect (3N),
.\".BR getsockname (3N),
.\".BR listen (3N),
.\".BR socket (3N),
\f4unlink\fP(2)
.SH NOTES
.LP
Binding a name in the
.SM UNIX
domain creates a socket in the file system that must
be deleted by the caller when it is no longer
needed (using \f4unlink\f1(2)).
.LP
The rules used in name binding vary between communication domains.
.\" Consult the manual entries in section 4 for detailed information.
.LP
The type of address structure passed to \f4bind\fP() depends on the
address family.
UNIX domain sockets (address family \f4AF_UNIX\fP) require a \f4struct\fP
\f4socketaddr_un\fP as defined in \f4sys/un.h\f1;
Internet domain sockets (address family \f4AF_INET\fP)
require a \f4struct\fP \f4sockaddr_in\fP as defined in
\f4netinet/in.h\fP.
Other address families may require other structures.
Use the structure appropriate to the address family; cast the
structure address to a generic \f4caddr_t\fP in the call to
\f4bind\fP()
and pass the size of the structure in the \f4length\fP argument.