Synopsis
typedef struct {
  size_t max_receive_segment_size;
  size_t max_owned_receive_bytes;
  size_t max_send_segment_size;
  size_t max_owned_send_bytes;
  unsigned long idle_socket_shutdown;
  char autoPush;
} CTL_TCP_SOCKET_OPTIONS_t;

CTL_TCP_SOCKET_OPTIONS_t contains configuration information for a socket.

In lieu of the classic sockets getsockopt and setsockopt functions, the TCP layer presents and receives its options in a single structure.

A client socket should set these options before calling ctl_tcp_connect.

A server socket's only chance at legally manipulating this its options would be during the CTL_TCP_ACCEPT_FN_t callback, but all sockets for a given port are initialized with the CTL_TCP_SOCKET_OPTIONS_t contained in the CTL_TCP_PORT_OPTIONS_t for that port. In general, calling ctl_tcp_set_socket_options for an individual server socket is not required.

The structure has the following members:

max_receive_segment_size
Maximum size of a receive segment. This cannot be greater than 1460 for Ethernet transports.
max_owned_receive_bytes
Used to calculate the receive window and slow down the remote TCP, if required. For maximum efficiency, it should be a multiple of max_receive_segment_size.
max_send_segment_size
Maximum size of a sense segment. This cannot be greater than 1460 for Ethernet transports. When sending a segment for this socket, the network library will allocate the minimum of this value and what the remote advertises during the connect handshake.
max_owned_send_bytes
Used to slow down application code, if required. This value does not include big external buffers that are passed during blocking ctl_tcp_send. For maximum efficiency, this should be a multiple of the max_send_segment_size.
idle_socket_shutdown
In whole seconds. Set this to zero if an idle socket should be kept alive forever. Otherwise, when a socket is idle for longer than this value, the network library will gracefully close the socket and recover its resources by initiating a FIN handshake with the remote TCP.
Note

This structure should be set prior to a connection being established with a remote TCP. For a client socket, it means that the application layer may only set a socket's options between the calls to ctl_tcp_socket and ctl_tcp_connect. For a server socket, it means that the only place to modify the socket options is within the CTL_TCP_ACCEPT_FN_t callback function.

See Also

ctl_tcp_get_socket_options, ctl_tcp_set_socket_options, ctl_tcp_connect