windows: fix that an immediate connect error is not seen and the socket is stuck...
authorbeware <beware@bircd.org>
Tue, 12 Oct 2021 21:32:15 +0000 (21:32 +0000)
committerbeware <beware@bircd.org>
Tue, 12 Oct 2021 21:32:15 +0000 (21:32 +0000)
git-svn-id: file:///svnroot/lcore/trunk@163 b1de8a11-f9be-4011-bde0-cc7ace90066a

lsocket.pas

index f359a55521de4b5f51802fba6033d865b85a069c..6a4034d2e83ebafe1c99b74b512d578be51326b6 100644 (file)
@@ -256,13 +256,16 @@ begin
     end else begin\r
       state :=wsconnecting;\r
       {$ifdef mswindows}\r
+        //beware: atleast on windows, wsaasyncselect set interest in events before connecting, or a connect error isn't seen if it happens immediately during connect\r
+        eventcore.rmasterset(fdhandlein,false);\r
+        eventcore.wmasterset(fdhandleout);\r
         //writeln(inaddr.inaddr.port);\r
         winsock.Connect(fdhandlein,winsock.psockaddr(@inADDR)^,getaddrsize);\r
       {$else}\r
         system_Connect(fdhandlein,inADDR,getaddrsize);\r
+        eventcore.rmasterset(fdhandlein,false);\r
+        eventcore.wmasterset(fdhandleout);\r
       {$endif}\r
-      eventcore.rmasterset(fdhandlein,false);\r
-      eventcore.wmasterset(fdhandleout);\r
       if trymoreips then connecttimeout.enabled := true;\r
     end;\r
     //sendq := '';\r