Stupid typo fix
[senf.git] / Socket / TCPSocketHandle.cc
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     \brief TCPv4SocketHandle and TCPv6SocketHandle non-inline non-template implementation
25  */
26
27 #include "TCPSocketHandle.hh"
28 //#include "TCPSocketHandle.ih"
29
30 // Custom includes
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <sys/ioctl.h>
34
35 #include "Utils/Exception.hh"
36
37 //#include "TCPSocketHandle.mpp"
38 #define prefix_
39 ///////////////////////////////cc.p////////////////////////////////////////
40
41 prefix_ void senf::TCPv4SocketProtocol::init_client()
42     const
43 {
44     int sock = ::socket(PF_INET,SOCK_STREAM,0);
45     if (sock < 0)
46         throw SystemException(errno);
47     body().fd(sock);
48 }
49
50 prefix_ void
51 senf::TCPv4SocketProtocol::init_client(INet4Address const & address)
52     const
53 {
54     init_client();
55     connect(address);
56 }
57
58 prefix_ void senf::TCPv4SocketProtocol::init_server()
59     const
60 {
61     int sock = ::socket(PF_INET,SOCK_STREAM,0);
62     if (sock < 0)
63         throw SystemException(errno);
64     body().fd(sock);
65 }
66
67 prefix_ void senf::TCPv4SocketProtocol::init_server(INet4Address const & address,
68                                                            unsigned backlog)
69     const
70 {
71     init_server();
72     bind(address);
73     reuseaddr(true);
74     if (::listen(body().fd(),backlog) < 0)
75         throw SystemException(errno);
76 }
77
78 prefix_ std::auto_ptr<senf::SocketProtocol> senf::TCPv4SocketProtocol::clone()
79     const
80 {
81     return std::auto_ptr<SocketProtocol>(new TCPv4SocketProtocol());
82 }
83
84 ///////////////////////////////cc.e////////////////////////////////////////
85 #undef prefix_
86 //#include "TCPSocketHandle.mpp"
87
88 \f
89 // Local Variables:
90 // mode: c++
91 // c-file-style: "senf"
92 // End: