#include <sys/types.h>
#include <sys/socket.h>
int bind(int socket_descriptor,
struct sockaddr *local_address,
int address_length)
|
The bind() function is used to associate a local address with a socket.
Parameters
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
The sa_family field identifies the address family to which the address belongs, and sa_data is the address whose format is dependent on the address family.
Return Value
bind() returns an integer. Possible values are:
Error Conditions
When a bind() fails, errno can be set to one of the following:
The process does not have the appropriate privileges to bind local_address to the socket pointed to by socket_descriptor (for example, if socket_descriptor is a socket with an address family of AF_INET, and the sockaddr_in structure (pointed to by local_address) specified a port that was restricted for use).
This error code indicates one of the following:
Note: For sockets with an address family of AF_NS, it is recommended that you specify 0 for the network number and the node address.
The address family specified in the address structure pointed to by local_address parameter cannot be used with the socket pointed to by the socket_descriptor parameter.
The system detected an address which was not valid while attempting to access the local_address parameter.
This error code is only returned on sockets that use the AF_UNIX address family.
This error code is only returned on sockets that use the AF_UNIX address family.
This error code is only returned on sockets that use the AF_UNIX address family.
This error code is only returned on sockets that use the AF_UNIX address family.
This error code is only returned on sockets that use the AF_UNIX address family.
Error Messages
Usage Notes
Also, processes trying to establish a connection with the connect() must have write access to the entry that is created.
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
The sin_family is the address family (always AF_INET for TCP and UDP), sin_port is the port number, and sin_addr is the internet address. The sin_zero field is reserved and must be hex zeros.
struct tel_addr {
unsigned short t_len;
char t_addrÕ40þ;
};
struct sockaddr_tel {
short stel_family;
struct tel_addr stel_addr;
char stel_zeroÕ4þ;
};
The stel_family is the address family (always AF_TELEPHONY), the stel_addr is the telephone number length and the telephone number itself. The stel_zero field is reserved.
Related Information
| Top | Sockets APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |