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)
{
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();
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Sendto failed: %s", strerror(errno)));
+ throw SystemError("Sendto failed", errno);
}
return ret;
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Recvfrom failed: %s", strerror(errno)));
+ throw SystemError("Recvfrom failed", errno);
}
addr_=SockAddr::create(addr);
return ret;
}
-IO::PollEvent DatagramSocket::get_initial_events() const
-{
- return IO::P_INPUT;
-}
-
} // namespace Net
} // namespace Msp