X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/4782a5c5afee47721cc617daa40dd29828342c2b..6cb6b7ede2d178e03fa817bc28474c175f5a93b9:/lcorewsaasyncselect.pas diff --git a/lcorewsaasyncselect.pas b/lcorewsaasyncselect.pas index a978c23..3f55f1a 100755 --- a/lcorewsaasyncselect.pas +++ b/lcorewsaasyncselect.pas @@ -2,8 +2,9 @@ unit lcorewsaasyncselect; interface + implementation -uses wcore,lcore,bsearchtree,sysutils,windows,winsock,pgtypes,messages,classes; +uses wcore,lcore,bsearchtree,sysutils,windows,winsock,pgtypes,messages,classes,lsocket; type twineventcore=class(teventcore) public @@ -78,10 +79,10 @@ end; procedure twineventcore.rmasterset(fd : integer;islistensocket : boolean); begin if islistensocket then begin - //writeln('setting accept watch for socket number ',fd); +// writeln('setting accept watch for socket number ',fd); dowsaasyncselect(fd,FD_ACCEPT or FD_CLOSE,0); end else begin - //writeln('setting read watch for socket number',fd); +// writeln('setting read watch for socket number',fd); dowsaasyncselect(fd,FD_READ or FD_CLOSE,0); end; end; @@ -116,23 +117,24 @@ var writetrigger : boolean; lasio : tlasio; begin - //writeln('got a message'); +// writeln('got a message'); Result := 0; // This means we handled the message if (ahwnd=hwndlcore) and (aumsg=wm_user) then begin - //writeln('it appears to be a response to our wsaasyncselect'); +// writeln('it appears to be a response to our wsaasyncselect'); socket := awparam; event := alparam and $FFFF; error := alparam shr 16; - //writeln('socket=',socket,' event=',event,' error=',error); +// writeln('socket=',socket,' event=',event,' error=',error); readtrigger := false; writetrigger := false; lasio := findtree(@fdreverse,inttostr(socket)); if assigned(lasio) then begin if (error <> 0) or ((event and FD_CLOSE) <> 0) then begin - if lasio.state = wsconnecting then begin - lasio.onsessionconnected(lasio,error); + if (lasio.state = wsconnecting) and (error <> 0) then begin + if lasio is tlsocket then tlsocket(lasio).connectionfailedhandler(error) + end else begin + lasio.internalclose(error); end; - lasio.internalclose(error); end else begin if (event and (FD_READ or FD_ACCEPT)) <> 0 then readtrigger := true; if (event and (FD_WRITE)) <> 0 then writetrigger := true; @@ -195,7 +197,7 @@ var begin eventcore := twineventcore.create; - if Windows.RegisterClass(MyWindowClass) = 0 then halt; + if Windows.RegisterClass(MyWindowClass) = 0 then halt; //writeln('about to create lcore handle, hinstance=',hinstance); hwndlcore := CreateWindowEx(WS_EX_TOOLWINDOW, MyWindowClass.lpszClassName, @@ -213,4 +215,5 @@ begin timerwrapperinterface := twintimerwrapperinterface.create(nil); WSAStartup($200, GInitData); + absoloutemaxs := maxlongint; end.