SSCRIPT TECHNICAL PAPER

Notes on some C networking functions
------------------------------------

The biggest problem for C networking functions on Linux is that the
Linux include tree is not BSD compatible. For example, for getsockopt,
SO_SNDBUF and SO_RCVBUF are not defined anywhere.

bind(sockfd, (struct sockaddr *)&listen_addr, listen_len)
This binds the socket to an address. The big problem here is that you
must also unlink it with the unlink() command, or use SO_REUSEADDR with
setsockopt(). listen_addr is:
listen_addr.sin_family = AF_INET;
listen_addr.sin_addr.s_addr = htonl(INADDR_ANY);
listen_addr.sin_port = htons(port);
and listen_len equals sizeof(listen_addr).

getsockopt(sockfd, SOL_SOCKET, <type>, (char *)&optval, &optlen);
Where type is one of: SO_DEBUG, SO_REUSEADDR, SO_KEEPALIVE,
SO_DONTROUTE, SO_LINGER, SO_BROADCAST, SO_OOBINLINE, SO_SNDBUF,
SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_TYPE,
SO_ERROR, optval equals 1, and optlen equals sizeof(int).
