dnsasync,\r
binipstuff,\r
sysutils,\r
- dnssync,\r
- //we don't actually make any use of lmessages in this app, we just\r
+ dnssync\r
+ //we don't actually make any use of the units below in this app, we just\r
//include it to check if it compiles ok ;)\r
- lmessages;\r
+ {$ifndef win32}\r
+ ,\r
+ lmessages,\r
+ unitfork\r
+ {$endif}\r
+ ;\r
{$ifdef win32}\r
{$R *.RES}\r
{$endif}\r
clientsocket : tlsocket;\r
sc : tsc;\r
task : tltask;\r
+ firststage : boolean;\r
procedure tsc.sessionavailable(sender: tobject;error : word);\r
begin\r
writeln('received connection');\r
\r
procedure tsc.sessionconnected(sender: tobject;error : word);\r
begin\r
- \r
+\r
if error=0 then begin\r
writeln('session is connected, local address is'+clientsocket.getxaddr);\r
\r
- if (clientsocket.addr = '127.0.0.1') or (clientsocket.addr = '::1') then begin\r
+ if firststage then begin\r
clientsocket.sendstr('hello world');\r
end else begin\r
clientsocket.sendstr('nick test'#13#10'user x x x x'#13#10);\r
writeln('closing client socket');\r
clientsocket.close;\r
\r
- writeln('looking up irc.ipv6.p10link.net using dnsasync');\r
+ writeln('looking up irc.p10link.net using dnsasync');\r
das := tdnsasync.Create(nil);\r
das.onrequestdone := sc.dnsrequestdone;\r
//das.forwardfamily := af_inet6;\r
- das.forwardlookup('irc.ipv6.p10link.net');\r
- \r
+ das.forwardlookup('irc.p10link.net');\r
+\r
end;\r
\r
procedure tsc.dnsrequestdone(sender:tobject;error : word);\r
tempbinip : tbinip;\r
tempbiniplist : tbiniplist;\r
begin\r
- writeln('irc.ipv6.p10link.net resolved to '+das.dnsresult+' connecting client socket there');\r
+ writeln('irc.p10link.net resolved to '+das.dnsresult+' connecting client socket there');\r
das.dnsresultbin(tempbinip);\r
tempbiniplist := biniplist_new;\r
biniplist_add(tempbiniplist,tempbinip);\r
clientsocket.addr := tempbiniplist;\r
clientsocket.port := '6667';\r
+ firststage := false;\r
clientsocket.connect;\r
//writeln(clientsocket.getxaddr);\r
das.free;\r
timer : tltimer;\r
ipbin : tbinip;\r
dummy : integer;\r
+ iplist : tbiniplist;\r
begin\r
+ lcoreinit;\r
ipbin := forwardlookup('invalid.domain',5);\r
writeln(ipbintostr(ipbin));\r
\r
writeln('2001:200::8002:203:47ff:fea5:3085 reverses to '+reverselookup(ipbin,5));\r
writeln('creating and setting up listen socket');\r
listensocket := tlsocket.create(nil);\r
- listensocket.addr := '::';\r
+ listensocket.addr := '';\r
listensocket.port := '12345';\r
listensocket.onsessionavailable := sc.sessionavailable;\r
writeln('listening');\r
serversocket.ondataavailable := sc.dataavailable;\r
writeln('creating and setting up client socket');\r
clientsocket := tlsocket.create(nil);\r
- clientsocket.addr := '::1';{'127.0.0.1';}\r
+ //try connecting to ::1 first and if that fails try 127.0.0.1\r
+ iplist := biniplist_new;\r
+ ipstrtobin('::1',ipbin);\r
+ biniplist_add(iplist,ipbin);\r
+ ipstrtobin('127.0.0.1',ipbin);\r
+ biniplist_add(iplist,ipbin);\r
+ clientsocket.addr := iplist;\r
clientsocket.port := '12345';\r
clientsocket.onsessionconnected := sc.sessionconnected;\r
clientsocket.ondataAvailable := sc.dataavailable;\r
clientsocket.onsessionclosed := sc.sessionclosed;\r
writeln('connecting');\r
+ firststage := true;\r
clientsocket.connect;\r
writeln('client socket is number ',clientsocket.fdhandlein);\r
writeln('creating and setting up timer');\r