X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/eaf53edbc38a2987348e92205a2fd2f1982bc2e1..95ddd8df198ff0f59c3a5e53c70719f5fcea6934:/lcoretest.dpr?ds=sidebyside diff --git a/lcoretest.dpr b/lcoretest.dpr index b84b8ec..da31cd6 100755 --- a/lcoretest.dpr +++ b/lcoretest.dpr @@ -11,11 +11,18 @@ uses dnsasync, binipstuff, sysutils, - dnssync, + 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, - unitfork; + {$ifndef win32} + , + {$ifndef nomessages} + lmessages, + unitwindowobject, + {$endif} + unitfork + {$endif} + ; {$ifdef win32} {$R *.RES} {$endif} @@ -30,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'); @@ -86,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); @@ -112,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); @@ -125,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; @@ -140,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); @@ -148,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)); @@ -162,7 +187,7 @@ 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'); @@ -174,12 +199,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');