Establishes a connection to a foreign address.
| Item | Description |
|---|---|
| so | The socket that was created by socreate(). |
| faddr | Foreign address to connect. |
The kern_soconnect kernel service establishes connection with a foreign address.
The kern_soconnect kernel service can be called from the process environment.
ksocket_t so;
struct sockaddr_in faddr;
int rc;
rc = kern_socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP);
if (rc != 0 )
{
return(-1);
}
bzero(&faddr, sizeof(struct sockaddr_in));
faddr.sin_family = AF_INET;
faddr.sin_port = 23456;
faddr.sin_len = sizeof(struct sockaddr_in);
faddr.sin_addr.s_addr = inet_addr("9.3.108.210");
rc = kern_soconnect(so, (struct sockaddr *) &faddr);
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.