X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstreamsocket.cpp;h=30c7efd77a35d2b257785e7af1ddb6b80f0156cd;hb=3103b110c863c19a56cc176a173cc30ddf13afec;hp=cf1a7b535203a1b3b643923d0ca09443e063c5b7;hpb=f59eded7c3e162bbdfc6db424c9badc730017698;p=libs%2Fnet.git diff --git a/source/streamsocket.cpp b/source/streamsocket.cpp index cf1a7b5..30c7efd 100644 --- a/source/streamsocket.cpp +++ b/source/streamsocket.cpp @@ -8,7 +8,7 @@ Distributed under the LGPL #ifndef WIN32 #include #endif -#include +#include #include #include #include "streamsocket.h" @@ -16,6 +16,19 @@ Distributed under the LGPL namespace Msp { namespace Net { +/** +Used by StreamListenSocket to construct a new socket from accept. +*/ +StreamSocket::StreamSocket(SocketHandle h, const SockAddr &paddr): + Socket(h, paddr), + connecting(false) +{ +#ifdef WIN32 + WSAEventSelect(handle, event, FD_READ|FD_CLOSE); +#endif + set_events(IO::P_INPUT); +} + /** Constructs a new StreamSocket. */ @@ -41,7 +54,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout) #ifdef WIN32 throw Exception(format("Connection polling failed: %d", WSAGetLastError())); #else - throw Exception(format("Connection polling failed: %s", strerror(errno))); + throw SystemError("Connection polling failed", errno); #endif else if(res>0) { @@ -57,7 +70,7 @@ int StreamSocket::poll_connect(const Time::TimeDelta &timeout) #ifdef WIN32 throw Exception(format("Connection failed: %d", err)); #else - throw Exception(format("Connection failed: %s", strerror(err))); + throw SystemError("Connection failed", err); #endif } @@ -116,7 +129,7 @@ int StreamSocket::connect(const SockAddr &addr) set_events(IO::P_OUTPUT); } else - throw Exception(format("Unable to connect: %s", strerror(errno))); + throw SystemError("Unable to connect", errno); } #endif @@ -137,19 +150,6 @@ int StreamSocket::connect(const SockAddr &addr) return (err==0)?0:1; } -/** -Used by StreamListenSocket to construct a new socket from accept. -*/ -StreamSocket::StreamSocket(SocketHandle h, const SockAddr &paddr): - Socket(h, paddr), - connecting(false) -{ -#ifdef WIN32 - WSAEventSelect(handle, event, FD_READ|FD_CLOSE); -#endif - set_events(IO::P_INPUT); -} - void StreamSocket::on_event(IO::PollEvent ev) { //cout<<"StreamSocket::on_event "<