[fpc-devel]ipv6 resolving

Johannes Berg johannes at sipsolutions.de
Sat Nov 22 23:05:07 CET 2003


Hi,

I've adjusted the netdb code to actually fix some things and resolve
ipv6 addresses, and follow cname pointers..

Attached is a patch :-)

Also attached is a test program but that will only work if you have ipv6
enabled and are connected to 6bone in some way. You can test the cname
resolving anyway though.
And the test program needs my other patch with ipv6 structures to work.

johannes
-- 
http://www.sipsolutions.de/
GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc
  Key-ID: 9AB78CA5 Johannes Berg <johannes at sipsolutions.de>
  Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5
-------------- next part --------------
program ip6test;

uses
  sockets,
  unix,
  errors,
  netdb,
  baseunix;

var
  dest: TInetSockAddr6;
  sock: LongInt;
  s: shortstring;
  i: integer;
  t1,t2:text;
  x: array of thostaddr6;

begin
  setlength(x, 100);
  setlength(x,resolvename6('www.6bone.net', x));
  if length(x) = 0 then halt(2);
  with dest do begin
    sin6_family := PF_INET6;
    sin6_port   := shorthosttonet(80);
    sin6_addr.u6_addr16 := x[0];
  end;
  sock := socket(PF_INET6, SOCK_STREAM, 6 {TCP});

  if Connect(sock, dest, sizeof(dest)) then begin
    sock2text(sock,t1,t2);
    writeln(t2, 'GET / HTTP/1.0');
    writeln(t2);
    while not eof(t1) do begin
      readln(t1, s);
      writeln(s);
    end;
  end else begin
    writeln('not connected: ',getlasterror, ': ', StrError(getlasterror));
  end;
  closesocket(sock);
end.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: netdb.patch
Type: text/x-patch
Size: 8391 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20031122/def892c3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20031122/def892c3/attachment.sig>


More information about the fpc-devel mailing list