INtime SDK Help
socket (legacy networking)
INtime Help

Creates an endpoint for communication.

int socket(
    int af,
    int type,
    int protocol
);

Parameters

af
An address format for interpreting addresses specified in later operations:
Value Format
AF_INET Internet addresses
type
Specifies the semantics of communication; one of these:
Value Meaning
SOCK_STREAM The socket will be used for connections.
SOCK_DGRAM The socket will be used for datagrams..
protocol
The protocol to be used with the socket. For a socket of type SOCK_STREAM or SOCK_DGRAM, specify 0 to get the default protocol, IPPROTO_TCP and IPPROTO_UDP, respectively. If you include <netinet/in.h>, these values are defined:
Literal Value Meaning
IPPROTO_TCP 6 Transmission control protocol
IPPROTO_UDP 17 User datagram protocol

Remarks

Sockets of type SOCK_STREAM are sequenced, reliable, two-way connection-based byte streams. A socket must be in a connected state before any data may be sent or received on it. A connection to another socket is created with connect. Once connected, data may be transferred using some variant of send and recv. When a session is complete, you must call shutdown.

The communications protocols used to implement a SOCK_STREAM ensure that data is not lost or duplicated. If a piece of data for which the peer protocol has buffer space cannot be successfully transmitted within a reasonable length of time, the connection is considered broken. Such calls indicate an error with -1 returns. The protocols optionally keep sockets viable by forcing transmissions approximately every minute, in the absence of other activity. An error is then indicated if no response can be elicited on an otherwise idle connection for an extended period (for example, five minutes).

SOCK_DGRAM sockets allow you to send and receive datagrams.

All sockets are, by default, SO_LINGER. If the socket promises reliable delivery of data, the system will block the process on a shutdown attempt until it is able to transmit the data or until it decides it is unable to deliver the information.

Return Values

A descriptor that references the socket.
Success.
-1 and the function sets errno to one of these values:
Failure.
EBADF Invalid file descriptor or file not opened for writing.
ENOSPC No space left on device.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/sys/socket.h sys/types.h
sys/socket.h
netiff3m.lib
   
See Also