[fpc-pascal] Re: Odyssey: SSockets and Threads.

silvioprog silvioprog at gmail.com
Thu Apr 25 21:41:06 CEST 2013


2013/4/25 Michael Van Canneyt <michael at freepascal.org>

> [...]
> Well, ssockets is very low level.
>
> fpselect() is mostly useful when you combine multiple file descriptors at
> once. Although it can be done, IMHO it makes little sense to create a
> select() method on the socket stream, since it would only have one socket
> handle.
>
> You can perfectly do a fpselect() with the handles of the streams that
> ssockets uses.
>
> Michael.


Nice.

The socket of Delphi and Synapse implements WaitForData:

function TWinSocketStream.WaitForData(Timeout: Longint): Boolean;
var
  FDSet: TFDSet;
  TimeVal: TTimeVal;
begin
  TimeVal.tv_sec := Timeout div 1000;
  TimeVal.tv_usec := (Timeout mod 1000) * 1000;
  FD_ZERO(FDSet);
  FD_SET(FSocket.SocketHandle, FDSet);
  Result := select(0, @FDSet, nil, nil, @TimeVal) > 0;
end;

I do not know where it would be used, it's just an observation hehe...
-- 
Silvio Cl├ęcio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130425/d0567ee4/attachment.html>


More information about the fpc-pascal mailing list