syswrite on closed socket? 
Author Message
 syswrite on closed socket?

my server program hangs when trying to syswrite on closed socket.

client usally send message before terminate so that server can delete
client from client list. but when client terminate abnormally, server
doesn't recognize and hangs when syswrite to this client.

how do I overcome this problem?
thanks for any help..



Sun, 16 May 2004 10:09:23 GMT  
 syswrite on closed socket?

Quote:
> my server program hangs when trying to syswrite on closed socket.

> client usally send message before terminate so that server can delete
> client from client list. but when client terminate abnormally, server
> doesn't recognize and hangs when syswrite to this client.

> how do I overcome this problem?

One way is to check writability via select(), probably via the
module IO::Select.

Anno



Sun, 16 May 2004 12:13:22 GMT  
 syswrite on closed socket?

Quote:

> my server program hangs when trying to syswrite on closed socket.

I suspect this is untrue.

Quote:
> client usally send message before terminate so that server can delete
> client from client list. but when client terminate abnormally, server
> doesn't recognize and hangs when syswrite to this client.

You are not talking out a closed socket.  You are talking about a
socket the peer of which is closed.

I suspect you are wrong about this anyhow.  I suspect that the client
has forked (or has been created by forking) since the socket was
opened and that the branch of the fork is holding the socket open.

Quote:
> how do I overcome this problem?

If I've guessed right, close unwanted file handles after forking.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Sun, 16 May 2004 19:54:21 GMT  
 syswrite on closed socket?

Quote:


> > my server program hangs when trying to syswrite on closed socket.

> > client usally send message before terminate so that server can delete
> > client from client list. but when client terminate abnormally, server
> > doesn't recognize and hangs when syswrite to this client.

> > how do I overcome this problem?

> One way is to check writability via select(), probably via the
> module IO::Select.

> Anno

Doesn't race condition exist between select and syswrite?


Mon, 17 May 2004 01:57:31 GMT  
 syswrite on closed socket?

Quote:


> > my server program hangs when trying to syswrite on closed socket.

> I suspect this is untrue.

> > client usally send message before terminate so that server can delete
> > client from client list. but when client terminate abnormally, server
> > doesn't recognize and hangs when syswrite to this client.

> You are not talking out a closed socket.  You are talking about a
> socket the peer of which is closed.

> I suspect you are wrong about this anyhow.  I suspect that the client
> has forked (or has been created by forking) since the socket was
> opened and that the branch of the fork is holding the socket open.

> > how do I overcome this problem?

> If I've guessed right, close unwanted file handles after forking.

Yes. I'm taking about a socket the peer of which is closed.
and I don't fork, I use 4 args select function for my multi server.
Thanks.


Mon, 17 May 2004 02:02:06 GMT  
 syswrite on closed socket?

Quote:

> my server program hangs when trying to syswrite on closed socket.

> client usally send message before terminate so that server can delete
> client from client list. but when client terminate abnormally, server
> doesn't recognize and hangs when syswrite to this client.

> how do I overcome this problem?
> thanks for any help..

my mistake.. problem was not this..
Thanks.


Tue, 18 May 2004 09:24:04 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. PERLFUNC: close - close file (or pipe or socket) handle

2. PERLFUNC: close - close file (or pipe or socket) handle

3. Proper way to close an IO::Socket or IO::Socket::INET

4. Sockets : Syswrite v. Print

5. Help to close inherited sockets/file descriptors after a fork

6. PerlIS sockets not closing? Probs w/ sendmail.pl

7. Net::TCP getline on closed socket

8. Quick way to test if a network socket has closed

9. Opening/closing sockets

10. Discerning an Open and Closed Socket...

11. A question about socket filehandles (how to close)

12. Closing down a connected network socket

 

 
Powered by phpBB® Forum Software