Re: [fpc-pascal] socket timeout

2013-04-17 Thread Fabio Luis Girardi
For connect, I wrote a unit that implements a connect timeout, see: http://sourceforge.net/p/pascalscada/code/HEAD/tree/trunk/src/scada/sockets_w32_w64.pas#l70 or http://sourceforge.net/p/pascalscada/code/HEAD/tree/trunk/src/scada/sockets_unix.pas#l48 If you want work in blocking mode after con

Re: [fpc-pascal] socket timeout

2013-04-17 Thread Rainer Stratmann
On Wednesday 17 April 2013 10:22:58 you wrote: > I thought MSG_DONTWAIT is actually the flag to switch to nonblocking mode, > isn't it? May be. > As a matter of fact, the fprecv() above would get a result of -1 > and a sockterror of "Try Again", which is exactly the behavior of > nonblocking read.

Re: [fpc-pascal] socket timeout

2013-04-17 Thread Xiangrong Fang
I thought MSG_DONTWAIT is actually the flag to switch to nonblocking mode, isn't it? As a matter of fact, the fprecv() above would get a result of -1 and a sockterror of "Try Again", which is exactly the behavior of nonblocking read. 2013/4/17 Rainer Stratmann > On Wednesday 17 April 2013 09:

Re: [fpc-pascal] socket timeout

2013-04-17 Thread Rainer Stratmann
On Wednesday 17 April 2013 09:17:09 you wrote: > Will this be a CPU hog: > > t := Now; > while fprecv(s, @buf, buf_len, MSG_DONTWAIT) < 0 do begin > if Now - t > 0.1 * timeout then Break; // approx. seconds > end; > > Thanks I did not read the whole thread, but that you favorite blocki

Re: [fpc-pascal] socket timeout

2013-04-17 Thread Xiangrong Fang
Will this be a CPU hog: t := Now; while fprecv(s, @buf, buf_len, MSG_DONTWAIT) < 0 do begin if Now - t > 0.1 * timeout then Break; // approx. seconds end; Thanks 2013/4/16 Luca Olivetti > Al 16/04/13 12:20, En/na Michael Schnell ha escrit: > > On 04/16/2013 11:26 AM, Xiangrong Fang

Re: [fpc-pascal] socket timeout

2013-04-16 Thread Luca Olivetti
Al 16/04/13 12:20, En/na Michael Schnell ha escrit: > On 04/16/2013 11:26 AM, Xiangrong Fang wrote: >> How can I set the connection and read/write timeout when using socket >> in free pascal? > I seem to remember that synapse can do this. Only in svn and it does it this way if FConnectionTimeout

Re: [fpc-pascal] socket timeout

2013-04-16 Thread Victor Campillo
On 16/04/13 11:26, Xiangrong Fang wrote: Hi there, How can I set the connection and read/write timeout when using socket in free pascal? I like the way it works now (blocking, NOT async), but the timeout is a bit too long. BTW, I hope the way to control timeout is withing the program and p

Re: [fpc-pascal] socket timeout

2013-04-16 Thread Mark Morgan Lloyd
Michael Schnell wrote: On 04/16/2013 11:26 AM, Xiangrong Fang wrote: How can I set the connection and read/write timeout when using socket in free pascal? I seem to remember that synapse can do this. Otherwise for non-standard protocols use fpconnect(), fpselect() etc. -- Mark Morgan Lloyd m

Re: [fpc-pascal] socket timeout

2013-04-16 Thread Michael Schnell
On 04/16/2013 11:26 AM, Xiangrong Fang wrote: How can I set the connection and read/write timeout when using socket in free pascal? I seem to remember that synapse can do this. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http:

[fpc-pascal] socket timeout

2013-04-16 Thread Xiangrong Fang
Hi there, How can I set the connection and read/write timeout when using socket in free pascal? I like the way it works now (blocking, NOT async), but the timeout is a bit too long. BTW, I hope the way to control timeout is withing the program and platform independent (instead of, e.g. set sysct