mtcp_setsockopt, mtcp_getsockopt − set and get options on mTCP sockets
int mtcp_setsockopt(mctx_t mctx, int sockid, int level, int optname, const void *optval, socklen_t optlen);
int mtcp_getsockopt(mctx_t mctx, int sockid, int level, int optname, const void *optval, socklen_t *optlen);
mtcp_setsockopt() and mtcp_getsockopt() 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_SOCKET level (the only available level available for mTCP at the moment) to adjust these options.
The arguments optval and optlen are used to set options values for mtcp_setsockopt(). For mtcp_getsockopt() optval identifies the buffer in which the value for the requested option is to be returned and the optlen argument is updated to indicate the actual size of the optval returned. It is the user’s responsibility to allocate memory for both optval and optlen arguments.
At the moment, mTCP only provides one optname named SO_ERROR that can only be used for mtcp_getsockopt() function. A successful execution of this function call with the specified option name returns the most recently recorded socket error for the particular connection (specific to the sockid socket descriptor).
Both the functions take an additional argument named mctx that represent the per-core mTCP context in an application (see mtcp_create_context() for details).
Returns 0 on success; -1 on failure. In case of failure, errno is set appropriately.
sockid is not a valid socket descriptor.
The socket referred to by sockid is not valid.
Either the level or the optname is not implemented.
mTCP development team <email@example.com>
This page is part of mTCP release 3.0 docs section. A description of the project, and information about reporting bugs, can be found at http://shader.kaist.edu/mtcp/.