X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/69b439a013e03cd1d3eb13da8bbbc20aa5bf5184..2579cad7a973072619a7fc17ff6af9cc75264972:/lcoretest.dpr?ds=sidebyside diff --git a/lcoretest.dpr b/lcoretest.dpr index b58e14a..8be5bea 100755 --- a/lcoretest.dpr +++ b/lcoretest.dpr @@ -11,10 +11,18 @@ uses dnsasync, binipstuff, sysutils, - dnssync, - //we don't actually make any use of lmessages in this app, we just + dnssync + //we don't actually make any use of the units below in this app, we just //include it to check if it compiles ok ;) - lmessages; + {$ifndef win32} + , + {$ifndef nomessages} + lmessages, + unitwindowobject, + {$endif} + unitfork + {$endif} + ; {$ifdef win32} {$R *.RES} {$endif} @@ -29,12 +37,16 @@ type procedure dnsrequestdone(sender:tobject;error : word); procedure sessionclosed(sender:tobject;error : word); end; + treleasetest=class(tlcomponent) + destructor destroy; override; + end; var listensocket : tlsocket; serversocket : tlsocket; clientsocket : tlsocket; sc : tsc; task : tltask; + firststage : boolean; procedure tsc.sessionavailable(sender: tobject;error : word); begin writeln('received connection'); @@ -85,11 +97,11 @@ end; procedure tsc.sessionconnected(sender: tobject;error : word); begin - + if error=0 then begin writeln('session is connected, local address is'+clientsocket.getxaddr); - if (clientsocket.addr = '127.0.0.1') or (clientsocket.addr = '::1') then begin + if firststage then begin clientsocket.sendstr('hello world'); end else begin clientsocket.sendstr('nick test'#13#10'user x x x x'#13#10); @@ -111,12 +123,12 @@ begin writeln('closing client socket'); clientsocket.close; - writeln('looking up irc.ipv6.p10link.net using dnsasync'); + writeln('looking up irc.p10link.net using dnsasync'); das := tdnsasync.Create(nil); das.onrequestdone := sc.dnsrequestdone; //das.forwardfamily := af_inet6; - das.forwardlookup('irc.ipv6.p10link.net'); - + das.forwardlookup('irc.p10link.net'); + end; procedure tsc.dnsrequestdone(sender:tobject;error : word); @@ -124,12 +136,13 @@ var tempbinip : tbinip; tempbiniplist : tbiniplist; begin - writeln('irc.ipv6.p10link.net resolved to '+das.dnsresult+' connecting client socket there'); + writeln('irc.p10link.net resolved to '+das.dnsresult+' connecting client socket there'); das.dnsresultbin(tempbinip); tempbiniplist := biniplist_new; biniplist_add(tempbiniplist,tempbinip); clientsocket.addr := tempbiniplist; clientsocket.port := '6667'; + firststage := false; clientsocket.connect; //writeln(clientsocket.getxaddr); das.free; @@ -139,6 +152,13 @@ procedure tsc.timehandler(sender:tobject); begin //writeln('got timer event'); end; + +destructor treleasetest.destroy; +begin + writeln('releasetest.destroy called'); + inherited destroy; +end; + procedure tsc.sessionclosed(sender:tobject;error : word); begin Writeln('session closed with error ',error); @@ -147,7 +167,13 @@ var timer : tltimer; ipbin : tbinip; dummy : integer; + iplist : tbiniplist; + releasetest : treleasetest; begin + lcoreinit; + releasetest := treleasetest.create(nil); + releasetest.release; + ipbin := forwardlookup('invalid.domain',5); writeln(ipbintostr(ipbin)); @@ -161,11 +187,12 @@ begin writeln('2001:200::8002:203:47ff:fea5:3085 reverses to '+reverselookup(ipbin,5)); writeln('creating and setting up listen socket'); listensocket := tlsocket.create(nil); - listensocket.addr := '::'; + listensocket.addr := ''; listensocket.port := '12345'; listensocket.onsessionavailable := sc.sessionavailable; writeln('listening'); listensocket.listen; + writeln('listen call returned'); writeln(listensocket.getxport); writeln('listen socket is number ', listensocket.fdhandlein); writeln('creating and setting up server socket'); @@ -173,12 +200,19 @@ begin serversocket.ondataavailable := sc.dataavailable; writeln('creating and setting up client socket'); clientsocket := tlsocket.create(nil); - clientsocket.addr := '::1';{'127.0.0.1';} + //try connecting to ::1 first and if that fails try 127.0.0.1 + iplist := biniplist_new; + ipstrtobin('::1',ipbin); + biniplist_add(iplist,ipbin); + ipstrtobin('127.0.0.1',ipbin); + biniplist_add(iplist,ipbin); + clientsocket.addr := iplist; clientsocket.port := '12345'; clientsocket.onsessionconnected := sc.sessionconnected; clientsocket.ondataAvailable := sc.dataavailable; clientsocket.onsessionclosed := sc.sessionclosed; writeln('connecting'); + firststage := true; clientsocket.connect; writeln('client socket is number ',clientsocket.fdhandlein); writeln('creating and setting up timer');