4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief BSDSocketProtocol public header */
31 #ifndef HH_SENF_Socket_Protocols_BSDSocketProtocol_
32 #define HH_SENF_Socket_Protocols_BSDSocketProtocol_ 1
35 #include <senf/Socket/SocketProtocol.hh>
36 #include <boost/cstdint.hpp>
38 //#include "BSDSocketProtocol.mpp"
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
43 /// \addtogroup protocol_facets_group
46 /** \brief Protocol facet providing basic BSD socket functionality
48 BSDSocketProtocol provides the basic BSD socket API as shared by all BSD sockets.
50 class BSDSocketProtocol
51 : public virtual SocketProtocol
54 std::pair<bool,unsigned> linger() const; ///< Return current linger status
55 /**< The value is returned in an std:pair. the first element
56 is \c true, if linger is active. The second value is
57 the linger timeout in seconds.
58 \returns linger state (enable disabled) and linger
60 void linger(bool enable, unsigned timeout=0) const; ///< Change linger status
61 /**< If linger is enabled, the timeout value specifies, how
62 long to wait before returning while data is unsent in
63 seconds. If this value is 0, a close() might wait
65 \param[in] enable \c true to activate linger
66 \param[in] timeout linger timeout in seconds */
67 boost::uint8_t priority() const; ///< Get packet priority assigned to outgoing packets
68 /**< This call will return the priority value assigned to
69 packets sent via this socket. Depending on the
70 protocol, this value may also be placed inside the
71 packet headers (for IPv4, this is the TOS value).
72 \returns current socket priority */
73 void priority(boost::uint8_t value) const; ///< Set packet priority (e.g. TOS)
74 /**< Changes the packet queueing priority. Additionally may
75 set protocol specific options. For IPv4 sockets, it
77 \param[in] value new socket priority */
79 int error() const; ///< Get and clear pending socket error
80 /**< This call will get <em>and clear</em> a pending socket
81 error. This includes asynchronous errors received via
82 the network (e.g. via ICMP). */
84 unsigned rcvbuf() const; ///< Check receive buffer size
85 /**< \returns size of receive buffer in bytes
86 \internal Linux doubles the buffer size internally when
87 changing it to cater for additional space needed by
88 the linux kernel. This call will therefore return
89 only half the value reported by the kernel. */
90 void rcvbuf(unsigned size) const; ///< Change receive buffer size
91 /**< \param[in] size new receive buffer size */
93 unsigned sndbuf() const; ///< Check send buffer size
94 /**< \returns size of send buffer in bytes
95 \internal Linux doubles the buffer size internally when
96 changing it to cater for additional space needed by
97 the linux kernel. This call will therefore return
98 only half the value reported by the kernel. */
99 void sndbuf(unsigned size) const; ///< Change size of send buffer
100 /**< \param[in] size new send buffer size */
104 /** \brief Protocol facet providing basic connection oriented BSD socket functions
106 AddressableBSDSocketProtocol provides the BSD socket API as it generically applies to
107 addressable (connection oriented) sockets.
109 class AddressableBSDSocketProtocol
110 : public virtual SocketProtocol
113 bool reuseaddr() const; ///< Return current reuseaddr state
114 /**< \returns \c true if \c SO_REUSEADDR is currently
115 enabled, \c false otherwise*/
116 void reuseaddr(bool value) const; ///< Set reuseraddr state
117 /**< A \c true value enables \c SO_REUSEADDR, \c false will
119 \param[in] value new \c SO_REUSEADDR state */
127 //-/////////////////////////////////////////////////////////////////////////////////////////////////
128 //#include "BSDSocketProtocol.cci"
129 //#include "BSDSocketProtocol.ct"
130 //#include "BSDSocketProtocol.cti"
131 //#include "BSDSocketProtocol.mpp"
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"
142 // comment-column: 40