X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/6cb6b7ede2d178e03fa817bc28474c175f5a93b9..6dc5aa808483fdb8531afc990f26f1138bf2ddac:/lcorewsaasyncselect.pas?ds=sidebyside diff --git a/lcorewsaasyncselect.pas b/lcorewsaasyncselect.pas index 3f55f1a..075d558 100755 --- a/lcorewsaasyncselect.pas +++ b/lcorewsaasyncselect.pas @@ -2,9 +2,14 @@ unit lcorewsaasyncselect; interface +procedure lcoreinit; implementation -uses wcore,lcore,bsearchtree,sysutils,windows,winsock,pgtypes,messages,classes,lsocket; + +uses + dnswin, //to call init + wcore,lcore,bsearchtree,sysutils,windows,winsock,pgtypes,messages,classes,lsocket; + type twineventcore=class(teventcore) public @@ -141,7 +146,9 @@ begin if readtrigger or writetrigger then lasio.handlefdtrigger(readtrigger,writetrigger); end; - dowsaasyncselect(socket,0,0); //reset watches + // don't reset the event manually for listen sockets to avoid unwanted + // extra onsessionavailible events + if (taddrint(findtree(@fdwatches,inttostr(socket))) and (FD_ACCEPT)) = 0 then dowsaasyncselect(socket,0,0); // if not a listen socket reset watches end; end else if (ahwnd=hwndlcore) and (aumsg=wm_dotasks) then begin //writeln('processing tasks'); @@ -195,7 +202,14 @@ var lpszClassName : 'lcoreClass'); GInitData: TWSAData; +var + inited:boolean; +procedure lcoreinit; begin + if (inited) then exit; + + dnswin.init; + eventcore := twineventcore.create; if Windows.RegisterClass(MyWindowClass) = 0 then halt; //writeln('about to create lcore handle, hinstance=',hinstance); @@ -214,6 +228,12 @@ begin onaddtask := winaddtask; timerwrapperinterface := twintimerwrapperinterface.create(nil); - WSAStartup($200, GInitData); + WSAStartup(2, GInitData); absoloutemaxs := maxlongint; + + wcoreinit; + + inited := true; +end; + end.