X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/9763940f8849e5c807566157829a1e6d2c9172ee..2ba734680253339d8b27208a1dfec5e2f220f3d8:/lsocket.pas?ds=inline diff --git a/lsocket.pas b/lsocket.pas index 4596f6b..6a4034d 100644 --- a/lsocket.pas +++ b/lsocket.pas @@ -256,13 +256,16 @@ begin end else begin state :=wsconnecting; {$ifdef mswindows} + //beware: atleast on windows, wsaasyncselect set interest in events before connecting, or a connect error isn't seen if it happens immediately during connect + eventcore.rmasterset(fdhandlein,false); + eventcore.wmasterset(fdhandleout); //writeln(inaddr.inaddr.port); winsock.Connect(fdhandlein,winsock.psockaddr(@inADDR)^,getaddrsize); {$else} system_Connect(fdhandlein,inADDR,getaddrsize); + eventcore.rmasterset(fdhandlein,false); + eventcore.wmasterset(fdhandleout); {$endif} - eventcore.rmasterset(fdhandlein,false); - eventcore.wmasterset(fdhandleout); if trymoreips then connecttimeout.enabled := true; end; //sendq := ''; @@ -534,7 +537,7 @@ function tlsocket.accept : longint; var FromAddrSize : LongInt; // i don't really know what to do with these at this FromAddr : TInetSockAddrV; // at this point time will tell :) - a:integer; + a,acceptlasterror:integer; begin {$ifdef secondlistener} if (lastsessionfromsecond) then begin @@ -550,11 +553,14 @@ begin {$else} result := system_accept(fdhandlein,fromaddr,fromaddrsize); {$endif} + + if (result = -1) then acceptlasterror := {$ifdef mswindows}getlasterror{$else}socketerror{$endif} else acceptlasterror := 0; + //now we have accepted one request start monitoring for more again eventcore.rmasterset(fdhandlein,true); if result = -1 then begin - raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting'); + raise esocketexception.create('error '+inttostr(acceptlasterror)+' while accepting'); end; if result > absolutemaxs then begin myfdclose(result);