Detecting a disconnected socket..

Detecting a disconnected socket..

Post by SongCom » Sat, 19 Aug 2000 04:00:00



Hi.

I got a problem same as Mr. Verbruggen.

Is there any way to detect a disconnected socket with no sending?
I want to close the socket if a client disconnects.
But I can getpeername() and I can get rtt even if a connection is closed..

Any techniques please..

 
 
 

Detecting a disconnected socket..

Post by David Schwart » Sat, 19 Aug 2000 04:00:00



> Hi.

> I got a problem same as Mr. Verbruggen.

> Is there any way to detect a disconnected socket with no sending?
> I want to close the socket if a client disconnects.
> But I can getpeername() and I can get rtt even if a connection is closed..

> Any techniques please..

        A dicsconnected socket will return an error on a call to recv. But you
can also use 'poll', if it's supported.

        DS

 
 
 

Detecting a disconnected socket..

Post by David Schwart » Sat, 19 Aug 2000 04:00:00



> Someone else already suggested poll. But let me add that maybe you're
> thinking about it the wrong way, in not wanting to use send. If you need
> to send something, do so. If that fails, close the connection. If you
> feel you need to read, do so. If you get eof, close. There wis hardly
> ever any real need to use poll.

        I presume you mean there is hardly any real need to use poll just to
detect a broken connection. There are plenty of cases where you really
need poll.

        DS

 
 
 

Detecting a disconnected socket..

Post by Martien Verbrugg » Sun, 20 Aug 2000 09:49:16


On Fri, 18 Aug 2000 18:18:33 GMT,

Quote:> Hi.

> I got a problem same as Mr. Verbruggen.

Are you referring to this Mr. Verbruggen? Because I can't recall ever
having had the problem you describe :) I think you'll find that I
supplied an answer in that thread, not the question.

Quote:> Is there any way to detect a disconnected socket with no sending?

Someone else already suggested poll. But let me add that maybe you're
thinking about it the wrong way, in not wanting to use send. If you need
to send something, do so. If that fails, close the connection. If you
feel you need to read, do so. If you get eof, close. There wis hardly
ever any real need to use poll.

Martien
--
Martien Verbruggen              |
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  |

 
 
 

Detecting a disconnected socket..

Post by SongCom » Sun, 20 Aug 2000 11:27:07




> On Fri, 18 Aug 2000 18:18:33 GMT,

> > Hi.

> > I got a problem same as Mr. Verbruggen.

> Are you referring to this Mr. Verbruggen? Because I can't recall ever
> having had the problem you describe :) I think you'll find that I
> supplied an answer in that thread, not the question.

> > Is there any way to detect a disconnected socket with no sending?

Ah.. Right. I meant you. I was confused.. Sorry..
Anyway, thank you.

-F.T.

 
 
 

Detecting a disconnected socket..

Post by Martien Verbrugg » Sun, 20 Aug 2000 04:00:00


On Fri, 18 Aug 2000 18:25:54 -0700,


> > Someone else already suggested poll. But let me add that maybe you're
> > thinking about it the wrong way, in not wanting to use send. If you need
> > to send something, do so. If that fails, close the connection. If you
> > feel you need to read, do so. If you get eof, close. There wis hardly
> > ever any real need to use poll.

>    I presume you mean there is hardly any real need to use poll just to
> detect a broken connection.

That's exactly what I meant. And I see that I wasn't really clear about
that.

Quote:>                             There are plenty of cases where you really
> need poll.

Indeed.

Martien
--
Martien Verbruggen              |
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  |

 
 
 

1. Sockets - How to detect if a client disconnects ?

Hi,

I have a server which accepts connections by a client. Now I'd like
to know, how the server can detect if the client dies, for example,
or disconnects. It seems, that the server can still read from the
socket (no error) and always gets the last byte, the client sent.

Any hints ?

Thanks for response !

--
-----------------------------------------------------------------------
Thomas Funke, Gasteinerstr. 29, 1000 Berlin 31, Germany, +49-30-8618224  
** Registered NeXT Developer **

-----------------------------------------------------------------------

2. I think 1.1.52 KILLED ME!

3. How to detect a disconnected socket?

4. My Linux crash because the newly added RAM!!

5. How to detect a socket disconnect on Solaris (without a zero length read)

6. Debian 2.0 under fireport40 troubles

7. Detecting disconnected sockets

8. PPP Config

9. How to detect server socket disconnected ?

10. Help - How to detect client disconnect (socket) ???

11. detecting network disconnect

12. Can DIP detect a CD disconnect???

13. Detecting modem disconnect in program