kern_socreate Kernel Service

Purpose

Used to create a socket of the specified address family and type. If the protocol is left unspecified (zero), then the system selects the protocol based on the address family and type.

Syntax

#include <sys/kern_socket.h>
int kern_socreate (int addressfamily, ksocket_t  *so, int type, int protocol)

Parameters

Item Description
addressfamily The address family for the newly created socket. The file <sys/socket.h> contains the definitions for the family. Currently AIX® supports:
AF_INET
Denotes the IPv4 Internet addresses.
AF_INET6
Denotes the IPv6 Internet addresses.
so The socket assigned by the create() call. The caller must pass the address of ksocket_t.
type The requested socket type. The file <sys/socket.h> contains the definition for the socket type. Currently AIX supports SOCK_STREAM.
protocol The file <netinet/in.h> contains the definition for the protocol. Currently AIX supports IPPROTO_TCP

Description

The kern_socreate kernel service creates a socket based on the address family, type and protocol.

Execution Environment

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

Examples

ksocket_t      so;
ksocket _t     so2;
kern_socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP); 
kern_socreate(AF_INET6, &so2, SOCK_STREAM, 0);

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.