X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FINet%2FTCPSocketHandle.cc;h=39af9cf40a235ab750a96d032599d3ced28d4fef;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=2f7f0ad4e44434a172d991fcc8b3ec8a89edeca4;hpb=2c4c9deecc7491fbfc916aeb41074dcb76e8a2c2;p=senf.git diff --git a/Socket/Protocols/INet/TCPSocketHandle.cc b/Socket/Protocols/INet/TCPSocketHandle.cc index 2f7f0ad..39af9cf 100644 --- a/Socket/Protocols/INet/TCPSocketHandle.cc +++ b/Socket/Protocols/INet/TCPSocketHandle.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ #include #include -#include "Utils/Exception.hh" +#include "../../../Utils/Exception.hh" //#include "TCPSocketHandle.mpp" #define prefix_ @@ -46,16 +46,16 @@ prefix_ void senf::TCPv4SocketProtocol::init_client() { int sock = ::socket(PF_INET,SOCK_STREAM,0); if (sock < 0) - throw SystemException(errno); - body().fd(sock); + SENF_THROW_SYSTEM_EXCEPTION(""); + fd(sock); } prefix_ void -senf::TCPv4SocketProtocol::init_client(INet4Address const & address) +senf::TCPv4SocketProtocol::init_client(INet4SocketAddress const & address) const { init_client(); - connect(address); + clientHandle().connect(address); } prefix_ void senf::TCPv4SocketProtocol::init_server() @@ -63,25 +63,19 @@ prefix_ void senf::TCPv4SocketProtocol::init_server() { int sock = ::socket(PF_INET,SOCK_STREAM,0); if (sock < 0) - throw SystemException(errno); - body().fd(sock); + SENF_THROW_SYSTEM_EXCEPTION(""); + fd(sock); } -prefix_ void senf::TCPv4SocketProtocol::init_server(INet4Address const & address, +prefix_ void senf::TCPv4SocketProtocol::init_server(INet4SocketAddress 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::TCPv4SocketProtocol::clone() - const -{ - return std::auto_ptr(new TCPv4SocketProtocol()); + serverHandle().bind(address); + if (::listen(fd(),backlog) < 0) + SENF_THROW_SYSTEM_EXCEPTION(""); } /////////////////////////////////////////////////////////////////////////// @@ -92,8 +86,8 @@ prefix_ void senf::TCPv6SocketProtocol::init_client() { int sock = ::socket(PF_INET6,SOCK_STREAM,0); if (sock < 0) - throw SystemException(errno); - body().fd(sock); + SENF_THROW_SYSTEM_EXCEPTION(""); + fd(sock); } prefix_ void @@ -101,7 +95,7 @@ senf::TCPv6SocketProtocol::init_client(INet6SocketAddress const & address) const { init_client(); - connect(address); + clientHandle().connect(address); } prefix_ void senf::TCPv6SocketProtocol::init_server() @@ -109,8 +103,8 @@ prefix_ void senf::TCPv6SocketProtocol::init_server() { int sock = ::socket(PF_INET6,SOCK_STREAM,0); if (sock < 0) - throw SystemException(errno); - body().fd(sock); + SENF_THROW_SYSTEM_EXCEPTION(""); + fd(sock); } prefix_ void senf::TCPv6SocketProtocol::init_server(INet6SocketAddress const & address, @@ -118,16 +112,10 @@ prefix_ void senf::TCPv6SocketProtocol::init_server(INet6SocketAddress const & a const { init_server(); - bind(address); + serverHandle().bind(address); reuseaddr(true); - if (::listen(body().fd(),backlog) < 0) - throw SystemException(errno); -} - -prefix_ std::auto_ptr senf::TCPv6SocketProtocol::clone() - const -{ - return std::auto_ptr(new TCPv6SocketProtocol()); + if (::listen(fd(),backlog) < 0) + SENF_THROW_SYSTEM_EXCEPTION(""); } ///////////////////////////////cc.e////////////////////////////////////////