DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

bind(SSC-osr5)


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-osr5), 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-osr5), connect(SSC-osr5), getsockname(SSC-osr5), inet(ADMP), listen(SSC-osr5), socket(SSC-osr5), unix(ADMP),

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005