X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/495c276d681a5b3f79d4b2af2ed36e8e5d9e993d..3745aa61ef489e4b143b5c753a006d0613a0297f:/lcoretest.dpr?ds=sidebyside diff --git a/lcoretest.dpr b/lcoretest.dpr index 9c4ec7c..8be5bea 100755 --- a/lcoretest.dpr +++ b/lcoretest.dpr @@ -11,7 +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 ;) + {$ifndef win32} + , + {$ifndef nomessages} + lmessages, + unitwindowobject, + {$endif} + unitfork + {$endif} + ; {$ifdef win32} {$R *.RES} {$endif} @@ -26,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'); @@ -65,7 +80,7 @@ begin receivecount := receivecount +1; if receivecount >50 then begin writeln('received over 50 bits of data, pausing to let the operator take a look'); - readln; + receivecount := 0; end; while pos(#10,receivebuf) > 0 do begin @@ -82,10 +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); @@ -107,11 +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); @@ -119,14 +136,15 @@ 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); + //writeln(clientsocket.getxaddr); das.free; end; @@ -134,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); @@ -142,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)); @@ -156,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'); @@ -168,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');