DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

bind(SSC)


bind -- bind a name to a socket

Syntax

cc ... -lsocket

#include <sys/types.h>
#include <sys/socket.h>

int bind (s, name, namelen) int s; const struct sockaddr *name; int namelen;

Description

bind( ) assigns a name to an unnamed socket. When a socket is created with socket(SSC), it exists in a name space (address family) but has no name assigned. ( ) requests that name be assigned to the socket.


NOTE: The rules used in name binding vary between ``communication domains''. (See protocols(SFF) for more information.) Consult the manual entries in the ADMP and SFF sections for detailed information.

Return values

A return value of zero indicates that the call succeeded. A return value of -1 indicates that an error occurred, and in this case an error code is stored in the global variable errno.

Diagnostics

The bind( ) call will fail if:

[EBADF]
s is not a valid descriptor.

[ENOTSOCK]
s is not a socket.

[EADDRNOTAVAIL]
The specified address is not available from the local machine.

[EADDRINUSE]
The specified address is already in use.

[EINVAL]
The socket is already bound to an address.

[EACCESS]
The requested address is protected, and the current user has inadequate permission to access it.

[EFAULT]
The name parameter is not in a valid part of the user address space.

Limitations

Currently, only the Internet and UNIX address families are supported.

See also

Intro(ADMP), Intro(SSC), connect(SSC), getsockname(SSC), inet(ADMP), listen(SSC), socket(SSC), unix(ADMP),

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003