libsocket
The libsocket documentation

This documentation is targeted at people who want to gain deeper insight into the libsocket source code. Normal library users should use the documentation provided in the doc/libsocket and doc/libsocket++ directories!

This is the documentation for the C and C++ library libsocket. libsocket is intended to simplify the use of internet and UNIX sockets. Information about how to build libsocket are placed here, and this page tells you how to use libsocket in your applications.

libsocket for C

To get started with libsocket for C, take a look at the hand-crafted documentation.

Detailed documentation is available here: libinetsocket; libunixsocket.

libsocket for C++

libsocket++ should also be easy to understand but it has a quite sophisticated class hierarchy.

libsocket++ consists of many C++ classes. Only the following are intended for use in external applications:

  • inet_stream, inet_stream_server (TCP/IP client and server)
  • inet_dgram_client, inet_dgram_server (UDP/IP client [unbound] and server [bound])
  • unix_stream_client, unix_stream_server (UNIX domain; STREAM client and server)
  • unix_dgram_client, unix_stream_client (UNIX domain; DGRAM unbound and bound sockets)
  • selectset, epollset

If a function fails, it throws a socket_exception object containing the error. Look here for detailed information. Therefore it's important to put libsocket++ operations inside try {...} catch () {...} blocks.

Libsocket++ uses C++11 to delete the copy constructors of the socket classes. This enables the destructor to safely close the socket; to pass a socket to other functions use call-by-reference, call-by-pointer or std::move and an rvalue-accepting function type:

void f(xyzsocket&);
void f(xyzsocket*);

Detailed documentation can be found in this doxygen documentation; easier documentation is available here