]> git.tdb.fi Git - libs/net.git/blobdiff - source/streamsocket.cpp
Fix a comparison operator on win32
[libs/net.git] / source / streamsocket.cpp
index 0f69111204af5ee0af783a158217ece68a7ecfa4..56df99335fb6c0b19f84264e73aa10f94a0ba248 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspnet
-Copyright © 2008  Mikkosoft Productions, Mikko Rasa
+Copyright © 2008-2009  Mikkosoft Productions, Mikko Rasa
 Distributed under the LGPL
 */
 
@@ -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.
 */
@@ -94,7 +107,7 @@ int StreamSocket::connect(const SockAddr &addr)
 
 #ifdef WIN32
        int err=WSAConnect(handle, &sa, size, 0, 0, 0, 0);
-       if(err=SOCKET_ERROR)
+       if(err==SOCKET_ERROR)
        {
                int err_code=WSAGetLastError();
                if(err_code==WSAEWOULDBLOCK)
@@ -131,25 +144,13 @@ int StreamSocket::connect(const SockAddr &addr)
        if(err==0)
        {
                connected=true;
+               set_events(IO::P_INPUT);
                signal_connect_finished.emit(0);
        }
 
        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 "<<ev<<'\n';