[fpc-pascal] fpselect does not work on linux

Rainer Stratmann RainerStratmann at t-online.de
Sat May 9 09:38:04 CEST 2009


To find out if a nonblocking socket has connected I use the following piece of 
code:

With windows that works, but with linux I get alwas the result that the socket 
is writable.

function is_writable_socket( sck : integer ) : boolean;
var
  fds : tfdset;
  tv  : timeval;
begin
  {$ifdef linux}   fpfd_zero( fds ); fpfd_set( sck , fds ); {$endif}
  {$ifdef windows}   fd_zero( fds );   fd_set( sck , fds ); {$endif}
  tv.tv_sec  := 0;
  tv.tv_usec := 0;
  //                 socket+1 , read , write , except , timeout
  {$ifdef linux}
  result := fpselect( sck + 1 , nil  , @fds  , nil    , @tv ) > 0;
  {$else}
  result :=   select( sck + 1 , nil  , @fds  , nil    , @tv ) > 0;
  {$endif}
end;



More information about the fpc-pascal mailing list