The Lprocess API takes the native API and maps it into a more traditional sockets format where sockets are represented by file-descriptor style integers instead of pointers to dctpSocket structures and data is exchanged through contiguous buffer regions instead of already in dctpPacket structures.
The following routines are supplied in ports/lprocess/dctpLprocessUApi.c. Code that uses these functions should #include "dctpLprocessApi.h". On errors, the functions generally return -1 and set 'errno' to extended error status.
- int dctpMkSocket(int domain, int type, char *scodetext) — Called to create a socket. 'domain' is DCTP_PF_INET for IPv4 or DCTP_PF_INET6 for IPv6 (only IPv4 supported in R0.10). 'type' is SOCK_DCCP_RAW for raw encapsulation or SOCK_DCCP_NAT for NAT encapsulation (only NAT supported in R0.10). 'scodetext' is the service code to use for the socket, in "SC:" notation. Returns a non-negative file descriptor for success or -1 for failure.
- int dctpBind(int sd, dctpSockaddr *addr) — Called to bind a socket to a local address in preparation for listening. Returns 0 for success and -1 for error.
- int dctpListen(int sd, int backlog) — Called to set socket in LISTEN state. 'backlog' is maximum number of pending connections to queue. Returns 0 on success and -1 on failure.
- int dctpAccept(int sd, dctpSockaddr *addr) — Called to accept incoming connections. If a pending connection is available, the function returns immediately. Otherwise it blocks until a connection is available (or an error occurs). Returns a new, non-negative, socket descriptor for the accepted connection on success, with '*addr' set to the remote peer's address and '*addrlen' set to the length of that address, or -1 for error.
- int dctpConnect(int sd, dctpSockaddr *addr, void *buf, int blen) — Called to initiate a connection request. 'addr' points to the address of the remote peer. 'buf' points to data of 'blen' length to include in the user data portion of the DCCP-Request packet. The call blocks until the the connection reaches the PARTOPEN state or an error occurs. Returns 0 on success and -1 on error.
- int dctpSend(int sd, void *msg, int mlen) — Called to send data on a socket. 'mlen' bytes beginning at 'msg' are transmitted, or queued for later transmission. If the transmission queue is full, the function blocks until room is available. Returns 'mlen' on success or -1 for error.
- int dctpRecv(int sd, void *buf, uint_t blen) — Called to receive data from a socket. Up to 'blen' bytes from the next packet on the receive queue are copied to 'buf'. If the packet's data are longer than 'blen' the excess is discarded. If no packets are on the queue the function blocks until one is received or there is an error. Returns the number of bytes copied (0 is a valid value) or -1 for error.
- int dctpClose(int sd) — Called to close the socket. If the socket is in data transfer state, this initiates a close procedure. If the socket is listening that is stopped and any pending connections are closed. After a call to dctpClose the socket descriptor must not be used again, and may be allocated to another socket. Returns 0 on success or -1 for error.
- int dctpSetSockopt(int sd, int optname, void *optval, int optlen, int mandatory) — Called to set a socket option. 'optname' is the name of the option to set. 'optval' is data of 'optlen' for the option. 'mandatory' is non-zero to include the mandatory option before this option. Returns 0 on success and -1 on failure.