X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/4782a5c5afee47721cc617daa40dd29828342c2b..13da3d2110165e8501869e896f1f17706f2058c1:/lcoretest.dpr?ds=inline diff --git a/lcoretest.dpr b/lcoretest.dpr index f6fe72b..da31cd6 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,20 +123,28 @@ 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); +var + tempbinip : tbinip; + tempbiniplist : tbiniplist; begin - writeln('irc.ipv6.p10link.net resolved to '+das.dnsresult+' connecting client socket there'); - clientsocket.addr := das.dnsresult; + 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; @@ -128,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); @@ -136,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)); @@ -150,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'); @@ -162,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');