SockSocket

The SockSocket() call creates an end point for communication and returns a socket descriptor representing the end point. Each socket type provides a different communication service.

Syntax:

>>--SockSocket(domain, type, protocol)-----------------------------------><

where:

domain

is the communication domain requested. It specifies the protocol family to be used. Currently, only the domain AF_INET is supported, which uses addresses in the Internet address format.

type

is the type of socket created. The following types are supported:

SOCK_STREAM

provides sequenced, two-way byte streams that are reliable and connection-oriented. It supports a mechanism for out-of-band data. Stream sockets are supported by the Internet (AF_INET) communication domain.

SOCK_DGRAM

provides datagrams, which are connectionless messages of a fixed length whose reliability is not guaranteed. Datagrams can be received out of order, lost, or delivered several times. Datagram sockets are supported by the Internet (AF_INET) communication domain.

SOCK_RAW

provides the interface to internal protocols, such as IP and ICMP. Raw sockets are supported by the Internet (AF_INET) communication domain.

protocol

is the protocol to be used with the socket. It can be IPPROTO_UDP, IPPROTO_TCP, or 0. If it is set to 0, which is the default, the system selects the default protocol number for the domain and socket type requested.

Sockets are deallocated with the SockClose() call.

Return values:

A non-negative socket descriptor return value indicates successful execution of the call. The return value -1 indicates an error. You can get the specific error code SockSock_Errno() or SockPSock_Errno(). Possible values are:

EMFILE

The maximum number of sockets are currently in use.

EPROTONOSUPPORT

The protocol is not supported in the specified domain or the protocol is not supported for the specified socket type.

EPFNOSUPPORT

The protocol family is not supported.

ESOCKTNOSUPPORT

The socket type is not supported.

Note: SockSocket() interfaces with the C function socket().