1program ip6test; 2 3uses 4 sockets, 5 unix, 6 errors, 7 netdb, 8 baseunix; 9 10var 11 dest: TInetSockAddr6; 12 sock: LongInt; 13 s: shortstring; 14 i: integer; 15 t1,t2:text; 16 x: array of thostaddr6; 17 hname : string; 18 19Const 20 ip6hosttest = 'whatismyv6.com'; 21 22begin 23 hname:=ip6hosttest; 24 if paramcount>0 then 25 hname:=paramstr(1); 26 setlength(x, 100); 27 i:=resolvename6(hname, x); 28 if i=-1 then 29 begin 30 writeln('Domain not found, ',hname); 31 halt; 32 end; 33 setlength(x,i); 34 if length(x) = 0 then halt(2); 35 with dest do begin 36 sin6_family := PF_INET6; 37 sin6_port := shorthosttonet(80); 38 sin6_addr.u6_addr16 := x[0].u6_addr16; 39 end; 40 sock := fpsocket(PF_INET6, SOCK_STREAM, 6 {TCP}); 41 42 if fpConnect(sock, @dest, sizeof(dest))=0 then begin 43 sock2text(sock,t1,t2); 44 writeln(t2, 'GET / HTTP/1.0'); 45 writeln(t2); 46 while not eof(t1) do begin 47 readln(t1, s); 48 writeln(s); 49 end; 50 end else begin 51 writeln('not connected: ',socketerror, ': ', StrError(socketerror)); 52 end; 53 closesocket(sock); 54end. 55