b8354ca41826aaf8ce0b75feb4dc016ac5df9bba
[senf.git] / Socket / TCPSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24
25     \todo Implement possibly non-blocking connect and SO_ERROR in the
26     protocol interface
27  */
28
29 #ifndef HH_TCPSocketHandle_
30 #define HH_TCPSocketHandle_ 1
31
32 // Custom includes
33 #include "INetProtocol.hh"
34 #include "TCPProtocol.hh"
35 #include "BSDSocketProtocol.hh"
36 #include "FramingPolicy.hh"
37 #include "CommunicationPolicy.hh"
38 #include "ReadWritePolicy.hh"
39 #include "BufferingPolicy.hh"
40 #include "ProtocolClientSocketHandle.hh"
41 #include "ProtocolServerSocketHandle.hh"
42
43 //#include "TCPSocketHandle.mpp"
44 ///////////////////////////////hh.p////////////////////////////////////////
45
46 namespace senf {
47
48
49     typedef MakeSocketPolicy<
50         INet4AddressingPolicy,
51         StreamFramingPolicy,
52         ConnectedCommunicationPolicy,
53         ReadablePolicy,
54         WriteablePolicy,
55         SocketBufferingPolicy
56         >::policy TCPv4Socket_Policy;
57
58     class TCPv4SocketProtocol
59         : public ConcreteSocketProtocol<TCPv4Socket_Policy>,
60           public IPv4Protocol, 
61           public TCPProtocol,
62           public BSDSocketProtocol,
63           public AddressableBSDSocketProtocol
64     {
65     public:
66         ///////////////////////////////////////////////////////////////////////////
67         // internal interface
68
69         void init_client() const;
70         void init_client(INet4Address const & address) const;
71         void init_server() const;
72         void init_server(INet4Address const & address, unsigned backlog=1) const;
73
74         std::auto_ptr<SocketProtocol> clone() const;
75     };
76
77     typedef ProtocolClientSocketHandle<TCPv4SocketProtocol> TCPv4ClientSocketHandle;
78     typedef ProtocolServerSocketHandle<TCPv4SocketProtocol> TCPv4ServerSocketHandle;
79
80     typedef MakeSocketPolicy<
81         TCPv4Socket_Policy,
82         INet6AddressingPolicy
83         >::policy TCPv6Socket_Policy;
84
85     class TCPv6SocketProtocol
86         : public ConcreteSocketProtocol<TCPv6Socket_Policy>, 
87           public IPv6Protocol,
88           public TCPProtocol,
89           public BSDSocketProtocol,
90           public AddressableBSDSocketProtocol
91     {
92         /** \todo Implement */
93     };
94
95     typedef ProtocolClientSocketHandle<TCPv6SocketProtocol> TCPv6ClientSocketHandle;
96     typedef ProtocolServerSocketHandle<TCPv6SocketProtocol> TCPv6ServerSocketHandle;
97
98 }
99
100 ///////////////////////////////hh.e////////////////////////////////////////
101 //#include "TCPSocketHandle.cci"
102 //#include "TCPSocketHandle.ct"
103 //#include "TCPSocketHandle.cti"
104 #endif
105
106 \f
107 // Local Variables:
108 // mode: c++
109 // c-file-style: "senf"
110 // End: