linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question on socket connection
@ 2003-05-26  2:03 Lejanson C. Go
  2003-05-26  2:30 ` ronkhu
  2003-05-26  5:57 ` Glynn Clements
  0 siblings, 2 replies; 10+ messages in thread
From: Lejanson C. Go @ 2003-05-26  2:03 UTC (permalink / raw)
  To: linux-c-programming

how do you check if the socket has been disconnected?


^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: question on socket connection
@ 2003-05-26  6:56 Ranga Reddy M - CTD ,Chennai.
  2003-05-26  7:33 ` ronkhu
  0 siblings, 1 reply; 10+ messages in thread
From: Ranga Reddy M - CTD ,Chennai. @ 2003-05-26  6:56 UTC (permalink / raw)
  To: Glynn Clements, Lejanson C. Go; +Cc: linux-c-programming



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.

-- 
Glynn Clements <glynn.clements@virgin.net>
-
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

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: question on socket connection
@ 2003-05-26  8:02 Ranga Reddy M - CTD ,Chennai.
  2003-05-26  8:27 ` Glynn Clements
  2003-05-26  8:43 ` ronkhu
  0 siblings, 2 replies; 10+ messages in thread
From: Ranga Reddy M - CTD ,Chennai. @ 2003-05-26  8:02 UTC (permalink / raw)
  To: ronkhu, linux-c-programming


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

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: question on socket connection
@ 2003-05-26  8:44 Ranga Reddy M - CTD ,Chennai.
  2003-05-26 10:05 ` John T. Williams
  0 siblings, 1 reply; 10+ messages in thread
From: Ranga Reddy M - CTD ,Chennai. @ 2003-05-26  8:44 UTC (permalink / raw)
  To: Glynn Clements, Ranga Reddy M - CTD ,Chennai.; +Cc: ronkhu, linux-c-programming


Now Iam puting alarm (SIGALRM) on the reader side if There is no
data/response for some time,(according to my application manipulation).Iam
disconnecting the client connection.

In the above design client application is implented like that each 5 min or
(according to my application manipulation) will send a "KEEP ALIVE request
to the server". With this request Iam updating the client connection in the
server.

According to me this is OK, but Iam wasting the network bandwidth and if by
mistake this packet is lost then server disconnects the client connection.

Can any one give me a idea.

Thanks
------
Ranga

-----Original Message-----
From: Glynn Clements [mailto:glynn.clements@virgin.net]
Sent: Monday, May 26, 2003 1:58 PM
To: Ranga Reddy M - CTD ,Chennai.
Cc: ronkhu@ntsp.nec.co.jp; linux-c-programming
Subject: RE: question on socket connection



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.

The socket won't be "closed" until the other end is rebooted or
powered up and sends a RST, or (if SO_KEEPALIVE is used) until the
kernel times out the connection.

> Client does not give any indication of socket close.Then, I think server
> will does not know about the status of the client.

Correct. If you don't get a response, there's no way to tell whether
that's due to a transient network fault, or because the other end has
crashed or is powered off.

> 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.

No. The "Nagle algorithm" is for coalescing many small writes into
fewer, larger packets.

TCP keep-alive is something else; it involves sending occasional
zero-byte packets when the connection would otherwise be idle in order
to detect whether the remote end is still functioning.

> Is there any way to trace???

I don't understand that question.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-05-26 10:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-26  2:03 question on socket connection Lejanson C. Go
2003-05-26  2:30 ` ronkhu
2003-05-26  5:57 ` Glynn Clements
  -- strict thread matches above, loose matches on Subject: below --
2003-05-26  6:56 Ranga Reddy M - CTD ,Chennai.
2003-05-26  7:33 ` ronkhu
2003-05-26  8:02 Ranga Reddy M - CTD ,Chennai.
2003-05-26  8:27 ` Glynn Clements
2003-05-26  8:43 ` ronkhu
2003-05-26  8:44 Ranga Reddy M - CTD ,Chennai.
2003-05-26 10:05 ` John T. Williams

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).