X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdatagramsocket.cpp;h=7944532aa673a4e09ae0ae619bc98e719e381e62;hb=02a6ddf010b763c6b08e706bf0c771c0fd250d25;hp=1394ffa59db669965f94564a777385ac85e91ce6;hpb=f59eded7c3e162bbdfc6db424c9badc730017698;p=libs%2Fnet.git diff --git a/source/datagramsocket.cpp b/source/datagramsocket.cpp index 1394ffa..7944532 100644 --- a/source/datagramsocket.cpp +++ b/source/datagramsocket.cpp @@ -14,7 +14,12 @@ namespace Net { DatagramSocket::DatagramSocket(Family f, int p): Socket(f, SOCK_DGRAM, p) -{ } +{ +#ifdef WIN32 + WSAEventSelect(handle, event, FD_READ|FD_CLOSE); +#endif + set_events(IO::P_INPUT); +} int DatagramSocket::connect(const SockAddr &addr) { @@ -25,7 +30,7 @@ int DatagramSocket::connect(const SockAddr &addr) int err=::connect(handle, &sa, size); if(err==-1) - throw Exception(format("Unable to connect: %s", strerror(errno))); + throw SystemError("Unable to connect", errno); delete peer_addr; peer_addr=addr.copy(); @@ -56,7 +61,7 @@ unsigned DatagramSocket::sendto(const char *buf, unsigned size, const SockAddr & if(errno==EAGAIN) return 0; else - throw Exception(format("Sendto failed: %s", strerror(errno))); + throw SystemError("Sendto failed", errno); } return ret; @@ -78,7 +83,7 @@ unsigned DatagramSocket::recvfrom(char *buf, unsigned size, SockAddr *&addr_) if(errno==EAGAIN) return 0; else - throw Exception(format("Recvfrom failed: %s", strerror(errno))); + throw SystemError("Recvfrom failed", errno); } addr_=SockAddr::create(addr); @@ -86,10 +91,5 @@ unsigned DatagramSocket::recvfrom(char *buf, unsigned size, SockAddr *&addr_) return ret; } -IO::PollEvent DatagramSocket::get_initial_events() const -{ - return IO::P_INPUT; -} - } // namespace Net } // namespace Msp