Socket options are used to control a socket communication. New options
can be set and old value of the options can be retrived at the protocol
level or at the socket level by using setopt
and
getopt
member functions. In addition, you can also use special
member functions to get and set specific options.
In what follows,
s
is a sockbuf
object
opval
is an integer and denotes the option value
op
is of type sockbuf::option
and must be one of
sockbuf::so_error
used to retrieve and clear error status
sockbuf::so_type
used to retrieve type of the socket
sockbuf::so_debug
is used to specify recording of debugging
information
sockbuf::so_reuseaddr
is used to specify the reuse of local address
sockbuf::so_keepalive
is used to specify whether to keep connections
alive or not
sockbuf::so_dontroute
is used to specify whether to route messages
or not
sockbuf::so_broadcast
is used to specify whether to broadcast
sockbuf::sock_dgram
messages or not
sockbuf::so_oobinline
is used to specify whether to inline
out-of-band data or not.
sockbuf::so_linger
is used to specify for how long to linger before
shutting down
sockbuf::so_sndbuf
is used to retrieve and to set the size of the
send buffer (communication channel buffer not sockbuf
's internal
buffer)
sockbuf::so_rcvbuf
is used to retrieve and to set the size of the
recv buffer (communication channel buffer not sockbuf
's internal
buffer)
s.getopt(op, &opval, sizeof(opval), oplevel)
sockbuf::option
op
at the
option level oplevel
in opval
. It returns the actual size
of the buffer opval
used. The default value of the oplevel
is sockbuf::sol_socket
.
s.setopt(op, &opval, sizeof(opval), oplevel)
sockbuf::option
op
at the
option level oplevel
to opval
. The default value of the
oplevel
is sockbuf::sol_socket
.
s.gettype()
s
. The return type is
sockbuf::type
.
s.clearerror()
s.debug(opval)
opval
is not -1, set the sockbuf::so_debug
option value
to opval
. In any case, return the old option value of
sockbuf::so_debug
option. The default value of opval
is
-1.
s.reuseaddr(opval)
opval
is not -1, set the sockbuf::so_reuseaddr
option value
to opval
. In any case, return the old option value of
sockbuf::so_reuseaddr
option. The default value of opval
is -1.
s.dontroute(opval)
opval
is not -1, set the sockbuf::so_dontroute
option value
to opval
. In any case, return the old option value of
sockbuf::so_dontroute
option. The default value of opval
is -1.
s.oobinline(opval)
opval
is not -1, set the sockbuf::so_oobinline
option value
to opval
. In any case, return the old option value of
sockbuf::so_oobinline
option. The default value of opval
is -1.
s.broadcast(opval)
opval
is not -1, set the sockbuf::so_broadcast
option value
to opval
. In any case, return the old option value of
sockbuf::so_broadcast
option. The default value of opval
is -1.
s.keepalive(opval)
opval
is not -1, set the sockbuf::so_keepalive
option value
to opval
. In any case, return the old option value of
sockbuf::so_keepalive
option. The default value of opval
is -1.
s.sendbufsz(opval)
opval
is not -1, set the new send buffer size to opval
.
In any case, return the old buffer size of the send buffer. The default
value of opval
is -1.
s.recvbufsz(opval)
opval
is not -1, set the new recv buffer size to opval
.
In any case, return the old buffer size of the recv buffer. The default
value of opval
is -1.
s.linger(tim)
tim
is positive, set the linger time to tim seconds.
If tim
is 0, set the linger off.
In any case, return the old linger time if it was set earlier.
Otherwise return -1. The default value of tim
is -1.