moved Sniffer into new Examples directory
[senf.git] / Socket / TCPSocketHandle.cc
index 7202fe3..1574919 100644 (file)
@@ -1,6 +1,6 @@
 // $Id$
 //
-// Copyright (C) 2006 
+// Copyright (C) 2006
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
@@ -38,6 +38,9 @@
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
+///////////////////////////////////////////////////////////////////////////
+// senf::TCPv4SocketProtocol
+
 prefix_ void senf::TCPv4SocketProtocol::init_client()
     const
 {
@@ -81,6 +84,52 @@ prefix_ std::auto_ptr<senf::SocketProtocol> senf::TCPv4SocketProtocol::clone()
     return std::auto_ptr<SocketProtocol>(new TCPv4SocketProtocol());
 }
 
+///////////////////////////////////////////////////////////////////////////
+// senf::TCPv6SocketProtocol::
+
+prefix_ void senf::TCPv6SocketProtocol::init_client()
+    const
+{
+    int sock = ::socket(PF_INET6,SOCK_STREAM,0);
+    if (sock < 0)
+        throw SystemException(errno);
+    body().fd(sock);
+}
+
+prefix_ void
+senf::TCPv6SocketProtocol::init_client(INet6SocketAddress const & address)
+    const
+{
+    init_client();
+    connect(address);
+}
+
+prefix_ void senf::TCPv6SocketProtocol::init_server()
+    const
+{
+    int sock = ::socket(PF_INET6,SOCK_STREAM,0);
+    if (sock < 0)
+        throw SystemException(errno);
+    body().fd(sock);
+}
+
+prefix_ void senf::TCPv6SocketProtocol::init_server(INet6SocketAddress const & address,
+                                                    unsigned backlog)
+    const
+{
+    init_server();
+    bind(address);
+    reuseaddr(true);
+    if (::listen(body().fd(),backlog) < 0)
+        throw SystemException(errno);
+}
+
+prefix_ std::auto_ptr<senf::SocketProtocol> senf::TCPv6SocketProtocol::clone()
+    const
+{
+    return std::auto_ptr<SocketProtocol>(new TCPv6SocketProtocol());
+}
+
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 //#include "TCPSocketHandle.mpp"
@@ -88,5 +137,8 @@ prefix_ std::auto_ptr<senf::SocketProtocol> senf::TCPv4SocketProtocol::clone()
 \f
 // Local Variables:
 // mode: c++
+// fill-column: 100
 // c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
 // End: