Re: [fpc-pascal] How to detect connection status of a socket

2013-04-28 Thread Ewald
On 22 Apr 2013, at 15:10, Xiangrong Fang wrote: 1) fpsend() just pass data to the OS's socket layer without try to determine if the connection is still alive, right? I suppose, but there exists an error code that might come in handy: ENotConn (see http://linux.die.net/man/2/send), which is

[fpc-pascal] How to detect connection status of a socket

2013-04-22 Thread Xiangrong Fang
Hi All, I am writing a redis client in fpc and found that even when the connection is closed by server (via redis CLIENT KILL), send and receive can still be done without error. i.e.: - fpsend returns the number of bytes sent - fprecv returns 0 (but NOT -1, which indicate a detectable error,

Re: [fpc-pascal] How to detect connection status of a socket

2013-04-22 Thread Marco van de Voort
In our previous episode, Xiangrong Fang said: I am writing a redis client in fpc and found that even when the connection is closed by server (via redis CLIENT KILL), I don't know the redis protocol is, but CLIENT KILL sounds like redis protocol, while you are trying to detect disconnect at

Re: [fpc-pascal] How to detect connection status of a socket

2013-04-22 Thread Michael Schnell
On 04/22/2013 02:23 PM, Xiangrong Fang wrote: How do I tell if a socket is still connected or not? The connected State of a TCP/IP socket is a rather complex issue. A TCP IP connection is either on or off. if it gets disconnected it is dead and can't be reactivated but by a new open. As

Re: [fpc-pascal] How to detect connection status of a socket

2013-04-22 Thread Xiangrong Fang
2013/4/22 Marco van de Voort mar...@stack.nl In our previous episode, Xiangrong Fang said: I am writing a redis client in fpc and found that even when the connection is closed by server (via redis CLIENT KILL), I don't know the redis protocol is, but CLIENT KILL sounds like redis

Re: [fpc-pascal] How to detect connection status of a socket

2013-04-22 Thread Xiangrong Fang
2013/4/22 Michael Schnell mschn...@lumino.de As long as no event happens to one of the sites, the socket is esteemed connected by this site. This does not mean that the other site thinks the same OK, as connection status is a complex issue, I try to put it in another way: 1) fpsend() just