Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 8

bind()

Bind a name to a socket

Synopsis:

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

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

Arguments:

s
The file descriptor to be bound.
name
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.
namelen
The length of the sockaddr structure pointed to by name.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

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.


Note: The bind() function assigns a local address. Use connect() to assign a remote address.

The rules used for binding names vary between communication domains.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EACCES
The requested address is protected, and the current user has inadequate permission to access it.
EADDRINUSE
The specified address is already in use.
EADDRNOTAVAIL
The specified address isn't available from the local machine.
EBADF
Invalid descriptor s.
EFAULT
The name parameter isn't in a valid part of the user address space.
EINVAL
The socket is already bound to an address.
ENOTSOCK
The given file descriptor isn't for a socket.

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

ICMP, IP, TCP, and UDP protocols

connect(), getsockname(), listen(), socket()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 205

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/b/bind.html on line 205