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 returned by send().


> 
> 2) is it normal that in BLOCK mode, recv returns 0?  i.e. if I receive a 0 
> from fprecv(), I can say that the connection is closed by the other end (if 
> there is no detectable socketerror), right?
> 

Yes, if recv() return 0, it mens the client disconnected. If it returns -1, 
errno will be set. From http://linux.die.net/man/2/recv (see `return value`):
        "These calls return the number of bytes received, or -1 if an error 
occurred. The return value will be 0 when the peer has performed an orderly 
shutdown."

Note that even in non-blocking mode, 0 means the socket is closed. If you 
received no data yet, you will get -1 as a return value and errno will be set 
to EAgain of EWouldBlock (see the link above).

Does this help or am I completely talking besides the point?

--
Ewald

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to