[fpc-pascal] fpbind ipv6 version
    Alexander Grotewohl 
    alex at dcclost.com
       
    Sun Oct 27 16:56:35 CET 2019
    
    
  
I sent this direct to him on accident but I don't think it worked 
anyways (bounced?)
Just some test code so not very pretty. It works, but IN6ADDR_ANY was 
missing and I'm not familiar enough with ipv6 to know how it might be 
defined in other languages.
uses sockets;
const
     IN6ADDR_ANY: array[0..3] of longint = (0, 0, 0, 0);
     test: string = 'derp derp derp'#13#10;
var
     servsoc: longint;
     clientsoc: longint;
     serv, client: TInetSockAddr6;
     i, res: longint;
begin
     servsoc:=fpsocket(AF_INET6, SOCK_STREAM, 0);
     fillchar(serv, sizeof(serv), 0);
     serv.sin6_family:=AF_INET6;
     serv.sin6_port:=htons(1234);
     serv.sin6_addr.s6_addr32:=IN6ADDR_ANY;
     fpbind(servsoc, @serv, sizeof(serv));
     if (fplisten(servsoc, 10) < 0) then
         writeln('ow');
     i:=sizeof(client);
     clientsoc:=fpaccept(servsoc, @client, @i);
     if (clientsoc = -1) then
         writeln('ow');
     res:=fpsend(clientsoc, @test[1], length(test), 0);
     if (res = -1) then
         writeln('ow')
     else
         writeln(res);
     closesocket(clientsoc);
     closesocket(servsoc);
end.
On 10/27/2019 5:32 AM, Michael Van Canneyt wrote:
>
>
> On Sat, 26 Oct 2019, Rainer Stratmann wrote:
>
>> https://www.freepascal.org/docs-html/current/rtl/sockets/fpbind.html
>>
>> Is there an example for IPV6?
>>
>> function fpbind(
>>  s: cint;
>>  addrx: psockaddr;
>>  addrlen: TSockLen
>> ):cint;
>>
>> I guess psockaddr is different in IPV6 version.
>
> No, it does not have to be.. The addrlen will differ of course. That's 
> why it is there to begin with. Maybe an overload could be added, I 
> would need to look into this to see if
> it is required.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
    
    
More information about the fpc-pascal
mailing list