X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FMainpage.dox;h=2296b5d965178cc16eb5e23efde7a706131ee0f6;hb=d0006132bfcb3ab442cf66b600ed3fad36f1ac2c;hp=09e881bbea18ad8530fd406326218bc91e07191e;hpb=cd9dd31c21fb021fe2c27ff52419b0e93340a964;p=senf.git diff --git a/Socket/Mainpage.dox b/Socket/Mainpage.dox index 09e881b..2296b5d 100644 --- a/Socket/Mainpage.dox +++ b/Socket/Mainpage.dox @@ -1,15 +1,18 @@ +namespace senf { + /** \mainpage The SENF Socket Library The Socket library provides a high level and object oriented abstraction of the BSD socket API. The abstraction is based on several concepts: - \li The basic visible interface is a handle object - (senf::FileHandle and it's derived classes) - \li The socket interface relies on a policy framework to configure - it's functionality + \li The basic visible interface is a \link handle_group handle + object \endlink + \li The socket interface relies on a \link policy_group policy + framework \endlink to configure it's functionality \li The rest of the socket API is accessible using a classic - inheritance hierarchy of protocol classes + inheritance hierarchy of \link protocol_group protocol classes + \endlink The handle/body architecture provides automatic reference counted management of socket instances, the policy framework provides @@ -19,67 +22,200 @@ dependent options. \see \ref usage \n - \ref extend \n + \ref handle_group \n + \ref policy_group \n + \ref protocol_group \n + \ref extend \n \ref implementation */ /** \page usage Using the Socket Library - \section socket_handle The socket handle - Whenever you use the socket library, what you will be dealing with - are senf::FileHandle derived instances. The socket library relies + are FileHandle derived instances. The socket library relies on reference counting to automatically manage the underlying socket representation. This frees you of having to manage the socket lifetime explicitly. + + \section usage_create Creating a Socket Handle + + To create a new socket handle (opening a socket), you will need to + use ProtocolClientSocketHandle or + ProtocolServerSocketHandle. You will probably not use these + templates as is but use proper typedefs (for example + TCPv4ClientSocketHandle or PacketSocketHandle). The + documentation for these socket handles are found in the protocol + class (for example TCPv4SocketProtocol or + PacketProtocol). + + \section usage_reusable Writing Reusable Components + + To make your code more flexible, you should not pass around your + socket in this form. Most of your code will be using only a small + subset of the ProtocolClientSocketHandle or + ProtocolServerSocketHandle API. If instead of using the + fully specified handle type you use a more incomplete type, you + allow your code to be used with all socket which fulfill the + minimal requirements of your code. + + This works, by defining a special reduced policy or handle for + your code: + + \code + typedef ClientSocketHandle< + MakeSocketPolicy< + ReadablePolicy, + StreamFramingPolicy, + ConnectedCommunicationPolicy > > MyReadableHandle; + + \endcode + + This defines \c MyReadableHandle as a ClientSocketHandle + which will have only read functionality. Your code expects a + stream interface (in contrast to a packet or datagram based + interface). You will not have \c write or \c readfrom members. \c + write will be disabled since the WritePolicy is unknown, \c + readfrom will be disabled since a socket with the + ConnectedCommunicationPolicy does not have a \c readfrom + member. + */ - \attention It is very important, to (almost) always pass the socket - handle by value. The socket handle is a very lightweight - class and designed to be used like an ordinary built-in type. This - is very important in combination with the policy interface. - - \section policy_framework The policy framework - - The policy framework conceptually implements a list of parallel - inheritance hierarchies each covering a specific interface aspect - of the socket handle. The socket handle itself only provides - minimal functionality. All further functionality is relayed to a - policy class, or more precisely, to a group of policy classes, one - for each policy axis. The policy axis are - -
policy | collection of policy classes, one for each + policy axis, instantiation of the SocketPolicy template |
policy axis | one aspect defined in the socket + policy, typedef and member of the SocketPolicy template |
policy class | implementation of a single policy + axis, class derived from the axis base class |
complete policy | socket policy where each + axis is specified completely |
incomplete policy | socket policy, where at + least one axis is not fully specified |
protocol class | definition of a protocol as a + class, class inheriting from ConcreteSocketProtocol. |
protocol facet | a class providing some subset of + the protocol interface, class derived from SocketProtocol but not + from ConcreteSocketProtocol |
policy interface | interface directly provided by + ClientSocketHandle/ServerSocketHandle and defined through the + policy | + +
protocol interface | interface provided by the + protocol class and accessible via the + ProtocolClientSocketHandle::protocol()/ProtocolServerSocketHandle::protocol() + member |