linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ronkhu <ronkhu@ntsp.nec.co.jp>
To: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: question on socket connection
Date: Mon, 26 May 2003 16:43:28 +0800	[thread overview]
Message-ID: <3ED1D3B0.9060505@hq.ntsp.nec.co.jp> (raw)
In-Reply-To: EF836A380096D511AD9000B0D021B527013AD275@narmada.techmas.hcltech.com

hmmm..
have u tried using select()?
instead of  invoking recv() on a socket that has no data? (in this case, 
u dont have to use MSG_DONTWAIT)

I dont know about the underlying TCP/IP mechanism.....
but recv() will still return -1  when the remote side of the socket 
closes... or when the application making use of that socket crashes for 
that matter....





Ranga Reddy M - CTD ,Chennai. wrote:

>Error -1: because of recv/send fail.
>Error EGAIN: this is because of MSG_DONTWAIT.
>
>Client and Server Both are running on different systems.What if client
>crashes or powered off.How does the underlaying TCP/IP layer works
>here,There is no time for TCP/IP to say socket close to server.
>
>Client does not give any indication of socket close.Then, I think server
>will does not know about the status of the client.
>
>I have read the article about the "Nagles allgoritham" . It sets a default
>time out of 2 hours. If there is not data on the socket for 2 hrs this will
>disconnect the socket.
>
>Is there any way to trace???
>
>
>-----Original Message-----
>From: ronkhu [mailto:ronkhu@ntsp.nec.co.jp]
>Sent: Monday, May 26, 2003 1:04 PM
>To: linux-c-programming
>Subject: Re: question on socket connection
>
>
>i think
>recv() would still return 0 if the remote side of the socket connection 
>has disconnected...
>
>if ur using MSG_DONTWAIT... -1 will be returned if there is no data to 
>be read...(as well as EGAIN)....
>thus, making it possible to differentiate from "no data" from 
>"disconnection event"
>
>
>
>
>
>
>Ranga Reddy M - CTD ,Chennai. wrote:
>
>  
>
>>If the socket is non-blocking mode, I mean if MSG_DONTWAIT send/recv of
>>flag is set....
>>If , the other end is no proper socket closing is done (system crash or
>>power down).
>>Then how to find the socket connection....?????
>>
>>
>>-----Original Message-----
>>From: Glynn Clements [mailto:glynn.clements@virgin.net]
>>Sent: Monday, May 26, 2003 11:28 AM
>>To: Lejanson C. Go
>>Cc: linux-c-programming
>>Subject: Re: question on socket connection
>>
>>
>>
>>Lejanson C. Go wrote:
>>
>> 
>>
>>    
>>
>>>how do you check if the socket has been disconnected?
>>>   
>>>
>>>      
>>>
>>Try reading from it; if read/recv return zero bytes, it's closed.
>>
>> 
>>
>>    
>>
>
>
>
>-
>To unsubscribe from this list: send the line "unsubscribe
>linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>  
>




  parent reply	other threads:[~2003-05-26  8:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-26  8:02 question on socket connection Ranga Reddy M - CTD ,Chennai.
2003-05-26  8:27 ` Glynn Clements
2003-05-26  8:43 ` ronkhu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-05-26  8:44 Ranga Reddy M - CTD ,Chennai.
2003-05-26 10:05 ` John T. Williams
2003-05-26  6:56 Ranga Reddy M - CTD ,Chennai.
2003-05-26  7:33 ` ronkhu
2003-05-26  2:03 Lejanson C. Go
2003-05-26  2:30 ` ronkhu
2003-05-26  5:57 ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ED1D3B0.9060505@hq.ntsp.nec.co.jp \
    --to=ronkhu@ntsp.nec.co.jp \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).