push
[NextIRCd.git] / src / IOHandler / IOEngine_win32.c
index 26ac0a64d6f484e38efeeb1112eb777d661cee18..ffc44e17fea86b856a163bada7614e3ef22ed046 100644 (file)
 #include "IOTimer.h"
 
 #ifdef WIN32
-
+#ifdef _WIN32_WINNT
+#undef _WIN32_WINNT
+#endif
 #define _WIN32_WINNT 0x501
-#include <windows.h>
 #include <winsock2.h>
+#include <windows.h>
 
 /* This is massively kludgy.  Unfortunately, the only performant I/O
  * multiplexer with halfway decent semantics under Windows is
@@ -65,6 +67,8 @@ static LRESULT CALLBACK engine_win32_wndproc(HWND hWnd, UINT uMsg, WPARAM wParam
                        return 0;
                case IDT_SOCKET:
                        iosock = engine_win32_get_iosock(wParam);
+                       if(!iosock)
+                               return 0;
                        events = WSAGETSELECTEVENT(lParam);
                        
                        if((events & FD_CONNECT)) {