X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FServerSocketHandle.hh;h=235b5903e3484c414d82d21d2a006ebfb0c052b1;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=42a6bae39b6c0df5415670657ef6c071adedfd2b;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Socket/ServerSocketHandle.hh b/Socket/ServerSocketHandle.hh index 42a6bae..235b590 100644 --- a/Socket/ServerSocketHandle.hh +++ b/Socket/ServerSocketHandle.hh @@ -1,9 +1,9 @@ -// $Id$ +// $Id:ServerSocketHandle.hh 218 2007-03-20 14:39:32Z tho $ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,8 +20,12 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HH_ServerSocketHandle_ -#define HH_ServerSocketHandle_ 1 +/** \file + \brief ServerSocketHandle public header + */ + +#ifndef HH_SENF_Socket_ServerSocketHandle_ +#define HH_SENF_Socket_ServerSocketHandle_ 1 // Custom includes #include @@ -33,41 +37,80 @@ //#include "ServerSocketHandle.mpp" ///////////////////////////////hh.p//////////////////////////////////////// -namespace satcom { -namespace lib { +namespace senf { + + /// \addtogroup handle_group + /// @{ + + template class ClientSocketHandle; + + /** \brief Generic SocketHandle with server interface + + This class provides the server side policy interface of the socket abstraction. + ServerSocketHandle defines the complete policy interface. It does not implement any + functionality itself however. All calls are forwarded to the following policy classes: - template class ClientSocketHandle; + + + + + + +
senf::ServerSocketHandle::bind AddressingPolicy::bind (\ref senf::AddressingPolicyBase)
senf::ServerSocketHandle::listen CommunicationPolicy::listen (\ref senf::CommunicationPolicyBase)
senf::ServerSocketHandle::local AddressingPolicy::local (\ref senf::AddressingPolicyBase)
senf::ServerSocketHandle::accept CommunicationPolicy::accept (\ref senf::CommunicationPolicyBase)
senf::ServerSocketHandle::acceptfrom CommunicationPolicy::accept (\ref senf::CommunicationPolicyBase)
- /** \brief + A ServerSocketHandle is only meaningful for connection oriented addressable protocols + (CommunicationPolicy is ConnectedCommunicationPolicy and AddressingPolicy is not + NoAddressingPolicy). + + It is important to note, that not all members are always accessible. Which are depends on + the \c Policy template argument. If any of the policy axis is left unspecified the + corresponding members will not be callable (you will get a compile time error). Even if + every policy axis is defined, some members might (and will) not exist if they are + meaningless for the protocol of the socket. This depends on the exact policy. + + To find out, which members are available, you have to check the documentation of the policy + classes. You can also find a summary of all members available in the leaf protocol class + documentation. */ - template + template class ServerSocketHandle - : public SocketHandle + : public SocketHandle { public: /////////////////////////////////////////////////////////////////////////// // Types - typedef typename Policy::AddressingPolicy::Address Address; + /// Address type from the addressing policy + typedef typename SPolicy::AddressingPolicy::Address Address; + /// 'Best' type for passing address as parameter + /** Depending on the type of \c Address, this will be either Address or Address + const &. See call_traits documentation in + the Boost.Utility library. + */ typedef typename boost::call_traits
::param_type AddressParam; - typedef ClientSocketHandle ClientSocketHandle; + /// Corresponding client socket handle with the same policy + typedef ClientSocketHandle ClientHandle; /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ - // no default constructor + // default default constructor // default copy constructor // default copy assignment // default destructor + // here to implement + ServerSocketHandle(); + // conversion constructors template ServerSocketHandle(ServerSocketHandle other, - typename SocketHandle::template IsCompatible::type * = 0); + typename SocketHandle::template IsCompatible::type * = 0); template - typename SocketHandle::template IsCompatible::type const & + typename SocketHandle::template IsCompatible::type const & operator=(ServerSocketHandle other); ///@} @@ -77,22 +120,73 @@ namespace lib { ///\name Server socket interface ///@{ + /** \brief Set local address + + For addressable protocols (AddressingPolicy is not NoAddressingPolicy), bind() will set + the local address of the socket. + + \param[in] addr Local socket address to assign + + \throws senf::SystemException + */ void bind (AddressParam addr); + + /** \brief Allow clients to connect to this server socket + + \todo This is very protocol specific, I don't want it in the policy + interface. Especially the backlog argument seems quite protocol specific to + me. However, we cannot listen() before we bind() so listen() cannot reside in the + constructor. We need to find a good solution here. + + \throws senf::SystemException + */ + // Possible solution: Make listen() an abstract method of the protocol interface, make the + // backlog parameter into a member living in the body or protocol class and set it using + // some accessor. Hmm ... this all seems somehow futile ... void listen (unsigned backlog=0); + /** \brief Query local address + + This member will return the address of the local socket in addressable protocols + (AddressingPolicy is not NoAddressingPolicy). + + There are two Variants of this member, one will return the address by value, the other + takes a reference argument to elide the copy operation. + + \throws senf::SystemException + */ Address local (); void local (Address & addr); + ///< Query local address + /**< \see \ref local() */ + + /** \brief Accept new connection + + If the handle is non-blocking, accept will NOT block. If no connection is available to + be returned, accept will return a ClientSocketHandle which is not valid() + + \throws senf::SystemException + + This variant ... + + \returns handle of new client connection + */ + ClientHandle accept (); + std::pair + acceptfrom (); ///< Accept new connection + /**< This variant will additionally return the remote + address of the client + \returns \c std::pair with client handle and client + address. + \see \ref accept() */ + ClientHandle acceptfrom (Address & addr); + ///< Accept new connection + /**< This variant will additionally return the remote + address of the client + \param[out] addr address + \returns handle of new client connection + \see \ref accept() */ - // If the handle is non-blocking, accept will NOT block. If no connection - // is available to be returned, accept will return a ClientSocketHandle - // which is not valid() - ClientSocketHandle - accept (); - std::pair - acceptfrom (); - ClientSocketHandle - acceptfrom (Address & addr); - ///@} static ServerSocketHandle cast_static(FileHandle handle); @@ -104,13 +198,14 @@ namespace lib { protected: ServerSocketHandle(FileHandle other, bool isChecked); - explicit ServerSocketHandle(std::auto_ptr protocol); + explicit ServerSocketHandle(std::auto_ptr body); private: - + }; -}} + /// @} +} ///////////////////////////////hh.e//////////////////////////////////////// //#include "ServerSocketHandle.cci" @@ -121,5 +216,10 @@ namespace lib { // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: