Associates the local network address to the socket.
| Item | Description |
|---|---|
| so | The socket that was created by the kern_socreate() system call. |
| laddr | Local address to be bound. |
The kern_sobind kernel service binds a local address to the socket.
The kern_sobind kernel service can be called from the process environment.
ksocket_t so;
struct sockaddr_in laddr;
int rc;
rc = kern_socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP);
if (rc != 0 )
{
return(-1);
}
bzero(&laddr, sizeof(struct sockaddr_in));
laddr.sin_family = AF_INET;
laddr.sin_port = 12345;
laddr.sin_len = sizeof(struct sockaddr_in);
laddr.sin_addr.s_addr = inet_addr("9.3.108.208");
rc = kern_sobind(so, (struct sockaddr *) &laddr);
if (rc != 0 )
{
return(-1);
}
| Item | Description |
|---|---|
| 0 | Upon Success |
| >0 | Error |
The nonzero return value is the error number that is defined in the /usr/include/sys/errno.h file.