Prepares to accept incoming connections on the socket.
Item | Description |
---|---|
so | The socket that was created by kern_socreate() and used in kern_sobind() |
backlog | Limit the number of connection requests that can be queued on this socket. The maximum value that can be passed to this parameter equals the minimum number of user backlog number and the network option somaxconn value. |
The kern_solisten kernel service prepares to accept incoming connection on the socket.
The kern_solisten kernel service can be called from the process environment.
struct mbuf *name = NULL;
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);
}
rc = kern_solisten(so, 5);
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.