ip6test.pp 814 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. program ip6test;
  2. uses
  3. sockets,
  4. unix,
  5. errors,
  6. netdb,
  7. baseunix;
  8. var
  9. dest: TInetSockAddr6;
  10. sock: LongInt;
  11. s: shortstring;
  12. i: integer;
  13. t1,t2:text;
  14. x: array of thostaddr6;
  15. begin
  16. setlength(x, 100);
  17. setlength(x,resolvename6('www.6bone.net', x));
  18. if length(x) = 0 then halt(2);
  19. with dest do begin
  20. sin6_family := PF_INET6;
  21. sin6_port := shorthosttonet(80);
  22. sin6_addr.u6_addr16 := x[0];
  23. end;
  24. sock := socket(PF_INET6, SOCK_STREAM, 6 {TCP});
  25. if Connect(sock, dest, sizeof(dest)) then begin
  26. sock2text(sock,t1,t2);
  27. writeln(t2, 'GET / HTTP/1.0');
  28. writeln(t2);
  29. while not eof(t1) do begin
  30. readln(t1, s);
  31. writeln(s);
  32. end;
  33. end else begin
  34. writeln('not connected: ',getlasterror, ': ', StrError(getlasterror));
  35. end;
  36. closesocket(sock);
  37. end.