uses\r
lcore,\r
lsocket,\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
lcorewsaasyncselect in 'lcorewsaasyncselect.pas',\r
{$else}\r
lcoreselect,\r
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
-{$ifdef win32}\r
+ {$ifndef mswindows}\r
+ ,\r
+ {$ifndef nomessages}\r
+ lcoremessages,\r
+ unitwindowobject,\r
+ {$endif}\r
+ unitfork\r
+ {$endif}\r
+ ;\r
+{$ifdef mswindows}\r
{$R *.RES}\r
{$endif}\r
\r
procedure dnsrequestdone(sender:tobject;error : word);\r
procedure sessionclosed(sender:tobject;error : word);\r
end;\r
+ treleasetest=class(tlcomponent)\r
+ destructor destroy; override;\r
+ end;\r
var\r
listensocket : tlsocket;\r
serversocket : tlsocket;\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
begin\r
//writeln('got timer event');\r
end;\r
+\r
+destructor treleasetest.destroy;\r
+begin\r
+ writeln('releasetest.destroy called');\r
+ inherited destroy;\r
+end;\r
+\r
procedure tsc.sessionclosed(sender:tobject;error : word);\r
begin\r
Writeln('session closed with error ',error);\r
timer : tltimer;\r
ipbin : tbinip;\r
dummy : integer;\r
+ iplist : tbiniplist;\r
+ releasetest : treleasetest;\r
begin\r
+ lcoreinit;\r
+ releasetest := treleasetest.create(nil);\r
+ releasetest.release;\r
+ \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
listensocket.listen;\r
+ writeln('listen call returned');\r
writeln(listensocket.getxport);\r
writeln('listen socket is number ', listensocket.fdhandlein);\r
writeln('creating and setting up server socket');\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