In article <(E-Mail Removed) >,
(E-Mail Removed) (Seunghwan Hong) writes:
>Hi~! ALL...
>
>I have a some question about recv() API.
>
>1. client side. (Server is EchoServer)
> - socket create.
> - connet to server.
> - shutdown(fd, 0); // receives disallowed.
> - send (); // OK
> - recv ();
> // this return value is 0. but I think this return value is -1
>(error)
>
>After calling shutdown() which parameter 'how' is 0, what is the
>return value of recv()?
I've never used shutdown(), but consider that recv() returns zero
if the connection has been closed. Zero sounds like a reasonable
response in your situation. Remember that when recv() returns zero,
it does _not_ mean that no data is ready; it means that the connection
has been closed.
>2. also client side.
> - socket create
> - connect to server.
> - pull out the lan cable.
> - recv ();
> // why didn't recv() return? I belive that recv() should return
>-1(error).
> // but the recv() is blocking.
> // Is it correct?
TCP/IP is a very robust and forgiving protocol. If you plug the
cable back in and some data comes through, recv() will return.
It doesn't throw up its hands if something - including hardware! -
isn't instantly ready. I've had a PPP connection to my ISP go
down while doing a big download; the program patiently waited
while I dialed back in, then continued where it left off.
There is a timeout, but it's quite long - 5 minutes or so.
--
/~\
(E-Mail Removed)lid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!