[fpc-pascal] FPC and IPv6, and BSD
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Mon Jul 23 23:24:55 CEST 2012
Mark Morgan Lloyd wrote:
> I'm trying to write a simple finger daemon, capable of both IP4 and IP6.
> At present it's using an unprivileged socket so as to avoid problems on
> unix platforms.
>
> I appear to be having problems at the bind() call for IP6 (returns -1),
> which I suspect is down to my incomplete understanding of the new
> sockaddr_in6 structure. Has anybody done this successfully?
On Linux >= 2.4.21 attempting to bind a v6 socket also binds the
corresponding v4. Appears to need
bindrc := 1;
fpsetsockopt(socket6, IPPROTO_IPV6, IPV6_V6ONLY, @bindrc,
SizeOf(bindRc));
to get them to work individually.
> As a subsidiary question: noting that a client has to be aware of this:
>
> sockaddr_in6 = packed Record
> {$ifdef SOCK_HAS_SINLEN} // as per RFC 2553
> sin6_len : cuint8;
> {$endif}
> sin6_family : sa_family_t;
> ..
>
> so that it initialises the sin6_len field if present (some BSD
> variants?), does it see that conditional automatically if defined?
> Otherwise how best to do it?
Anybody?
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list