kern_sobind Kernel Service

Purpose

Associates the local network address to the socket.

Syntax

#include <sys/kern_socket.h>
int  kern_sobind( ksocket_t  so, struct sockaddr *laddr )

Parameters

Item Description
so The socket that was created by the kern_socreate() system call.
laddr Local address to be bound.

Description

The kern_sobind kernel service binds a local address to the socket.

Execution Environment

The kern_sobind kernel service can be called from the process environment.

Examples

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); 		 
}		 

Return Values

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.