setsockopt TCP UDP
Set a specific option on a specific TCP socket. See function NetSock_OptSet for more information.
Files
net_bsd.h/net_bsd.c
Prototype
int setsockopt (int sock_id,
int level,
int opt_name,
void *p_opt_val,
sock_len_t opt_len);Arguments
sock_id
This is the socket ID returned by NetSock_Open()/socket() when the socket was created or by NetSock_Accept()/accept() when a connection was accepted.
level
Protocol level from which to retrieve the socket option.
opt_name
Socket option to set the value.
popt_val
Pointer to the socket option value to set.
opt_len
Option length.
Returned Value
0, if successful;
-1, otherwise.
Required Configuration
None.
Notes / Warnings
The supported options are:
Protocol level
SOL_SOCKET:SO_KEEPALIVESO_SNDBUF / SO_RCVBUFSO_SNDTIMEO / SO_RCVTIMEO
Protocol level
IPPROTO_IP:IP_TOSIP_TTL
Protocol level
IPPROTO_TCP:TCP_NODELAYTCP_KEEPCNTTCP_KEEPIDLETCP_INTVL
This function must be called after either listen() (in the server case) or connect() (in the client case) have been called.