]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/streamsocket.cpp
Implement an asynchronous name resolver class
[libs/net.git] / source / net / streamsocket.cpp
index 8a262454eca173dfcc6ef93f0fcd0d45c10582f7..85f2b00a05d33e7820a022f6bb0e83716d0829f5 100644 (file)
@@ -1,4 +1,6 @@
-#ifndef WIN32
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <sys/socket.h>
 #endif
 #include <cerrno>
@@ -71,6 +73,9 @@ bool StreamSocket::connect(const SockAddr &addr)
        if(err==0)
        {
                connected = true;
+#ifdef WIN32
+               WSAEventSelect(priv->handle, *priv->event, FD_READ|FD_CLOSE);
+#endif
                set_events(IO::P_INPUT);
                signal_connect_finished.emit(0);
        }
@@ -90,7 +95,7 @@ bool StreamSocket::poll_connect(const Time::TimeDelta &timeout)
 
                int err;
                socklen_t len = sizeof(int);
-               get_option(SOL_SOCKET, SO_ERROR, &err, &len);
+               priv->get_option(SOL_SOCKET, SO_ERROR, &err, &len);
 
                if(err!=0)
                {
@@ -119,7 +124,7 @@ void StreamSocket::on_event(IO::PollEvent ev)
        {
                int err;
                socklen_t len = sizeof(err);
-               get_option(SOL_SOCKET, SO_ERROR, &err, &len);
+               priv->get_option(SOL_SOCKET, SO_ERROR, &err, &len);
 
                connecting = false;
                connected = (err==0);