Hello,

Does fpSelect not work with UDP sockets?
It always returns 0, which means it did not see a packet.
Is anything wrong with this code?

Uses
  UnixType, BaseUnix, Sockets;

procedure abort (reason:string);
begin
  writeln (reason);
  halt;
end;

var
  sock: cint;
  adr : {TInet}SockAddr;
  rc  : cint;
  FDS : Tfdset;

begin
  sock := fpSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if sock = -1 then
     abort ('Error from fpSocket');

  adr.sin_family      := AF_INET;
  adr.sin_addr.s_addr := INADDR_ANY;
  adr.sin_port        := htons(53);
  rc := fpBind (sock, @adr, sizeof(adr));
  if rc <> 0 then
     abort ('Error from fpBind');

  Writeln ('send udp packet in less than 5 seconds');
  Fpfd_zero(FDS);
  FpFd_set (sock,FDS);
  rc := fpSelect (1,@FDS,nil,nil,5000);
  if rc = -1 then
     abort ('Error from fpSelect');
  if rc > 0 then
    Writeln ('Thank you !')
  else
    Writeln ('Too late !');
end.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to