mtcp_setsockopt

NAME

mtcp_setsockopt − set options on mTCP/mOS sockets

SYNOPSIS

#include <mtcp_api.h>

int mtcp_setsockopt(mctx_t mctx, int sockid, int level, int optname, const void *optval, socklen_t optlen);

DESCRIPTION

mtcp_setsockopt() manipulate options for the socket referred to by the sockid descriptor. These options may exist at multiple protocol levels. When manipulating socket options, the level at which the options resides and the name of the option must be specified. A user can use SOL_MONSOCKET level to adjust options for monitoring sockets.

The arguments optval and optlen are used to set options values for mtcp_setsockopt().

SOL_MONSOCKET socket level can be used by mtcp_setsockopt() to set a number of attributes pertaining to the socket.

MOS_CLIBUF

Dynamically adjust the size of the TCP receive ring buffer of the emulated client stack. The optval contains the size of the buffer that needs to be set as int, while optlen is equal to sizeof(int).

MOS_SVRBUF

Dynamically adjust the size of the TCP receive ring buffer of the emulated client stack. The optval contains the size of the buffer that needs to be set as int, while optlen is equal to sizeof(int).

MOS_CLIOVERLAP

Dynamically determine the policy on content overlap (e.g., overwriting with the retransmitted payload or not) for the client-side buffer. The optval can be either MOS_OVERLAP_POLICY_FIRST (to take the first data and never overwrite the buffer) or MOS_OVERLAP_POLICY_LAST (to always update the buffer with the last data), and optlen is equal to sizeof(int).

MOS_SVROVERLAP

Dynamically determine the policy on content overlap (e.g., overwriting with the retransmitted payload or not) for the server-side buffer. The optval can be either MOS_OVERLAP_POLICY_FIRST (to take the first data and never overwrite the buffer) or MOS_OVERLAP_POLICY_LAST (to always update the buffer with the last data), and optlen is equal to sizeof(int).

MOS_STOP_MON

Dynamically stop monitoring a flow for the specific side. This option can be used only with a MOS_SOCK_MONITOR_ACTIVE socket, which is given as a parameter in callback functions for every flow. The optval contains a side variable (MOS_SIDE_CLI, MOS_SIDE_SVR, or MOS_SIDE_BOTH), while optlen is equal to sizeof(int).

RETURN VALUE

Returns 0 on success; -1 on failure. In case of failure, errno is set appropriately.

ERRORS

EACCES

mctx is not valid.

EBADF

sockid is not a valid socket descriptor.

ENOTSOCK

The socket referred to by sockid is not valid.

ENOSYS

Either the level or the optname is not implemented.

EPERM

Permission to access a socket option is denied.

AUTHORS

mOS development team <mtcp-user@list.ndsl.kaist.edu>

EXAMPLES

http://mos.kaist.edu/guide/programmer/05_api_example.html#setting-monitoring-policy http://mos.kaist.edu/guide/programmer/05_api_example.html#disabling-packet-flow-monitoring

SEE ALSO

mtcp_socket(), mtcp_getsockopt()

COLOPHON

This page is part of mOS release 0.3 docs section. A description of the project, and information about reporting bugs, can be found at http://mos.kaist.edu/.