5d3b2c0e993f366ab6cb457331ab5091a8524294
[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 // TODO: Implement possibly non-blocking connect and SO_ERROR in the
24 // protocol interface
25
26 #ifndef HH_TCPSocketHandle_
27 #define HH_TCPSocketHandle_ 1
28
29 // Custom includes
30 #include "INetProtocol.hh"
31 #include "TCPProtocol.hh"
32 #include "BSDSocketProtocol.hh"
33 #include "FramingPolicy.hh"
34 #include "CommunicationPolicy.hh"
35 #include "ReadWritePolicy.hh"
36 #include "BufferingPolicy.hh"
37 #include "ProtocolClientSocketHandle.hh"
38 #include "ProtocolServerSocketHandle.hh"
39
40 //#include "TCPSocketHandle.mpp"
41 ///////////////////////////////hh.p////////////////////////////////////////
42
43 namespace satcom {
44 namespace lib {
45
46     typedef MakeSocketPolicy<
47         INet4AddressingPolicy,
48         StreamFramingPolicy,
49         ConnectedCommunicationPolicy,
50         ReadablePolicy,
51         WriteablePolicy,
52         SocketBufferingPolicy
53         >::policy TCPv4Socket_Policy;
54
55     class TCPv4SocketProtocol
56         : public ConcreteSocketProtocol<TCPv4Socket_Policy>,
57           public IPv4Protocol, 
58           public TCPProtocol,
59           public BSDSocketProtocol,
60           public AddressableBSDSocketProtocol
61     {
62     public:
63         ///////////////////////////////////////////////////////////////////////////
64         // internal interface
65
66         void init_client() const;
67         void init_client(INet4Address const & address) const;
68         void init_server() const;
69         void init_server(INet4Address const & address, unsigned backlog=1) const;
70
71         std::auto_ptr<SocketProtocol> clone() const;
72     };
73
74     typedef ProtocolClientSocketHandle<TCPv4SocketProtocol> TCPv4ClientSocketHandle;
75     typedef ProtocolServerSocketHandle<TCPv4SocketProtocol> TCPv4ServerSocketHandle;
76
77     typedef MakeSocketPolicy<
78         TCPv4Socket_Policy,
79         INet6AddressingPolicy
80         >::policy TCPv6Socket_Policy;
81
82     class TCPv6SocketProtocol
83         : public ConcreteSocketProtocol<TCPv6Socket_Policy>, 
84           public IPv6Protocol,
85           public TCPProtocol,
86           public BSDSocketProtocol,
87           public AddressableBSDSocketProtocol
88     {
89         // TODO: Implement
90     };
91
92     typedef ProtocolClientSocketHandle<TCPv6SocketProtocol> TCPv6ClientSocketHandle;
93     typedef ProtocolServerSocketHandle<TCPv6SocketProtocol> TCPv6ServerSocketHandle;
94
95 }}
96
97 ///////////////////////////////hh.e////////////////////////////////////////
98 //#include "TCPSocketHandle.cci"
99 //#include "TCPSocketHandle.ct"
100 //#include "TCPSocketHandle.cti"
101 #endif
102
103 \f
104 // Local Variables:
105 // mode: c++
106 // c-file-style: "satcom"
107 // End: