Socket State Before Call To Send()?

Socket State Before Call To Send()?

Post by Shane McDanie » Fri, 04 Jul 2003 02:42:35



I am having troublee determining if a socket is still connected to the
remote host before I make a call to send().

I know how to determine this in my code that makes the call to read(),
ie check if read() returns 0, but the code that does the read() does not
have access to certain variables I need to unset when the socket has
been terminated by the other side.

What I need to be able to do is to simply determine if a socket is still
connected to it's remote host without using a read() call, as the read
code is being done elsewhere and I don't want to mess up the actual
read()) call.

-shane

 
 
 

Socket State Before Call To Send()?

Post by Lorinczy Zsigmon » Fri, 04 Jul 2003 02:56:18


just call write, it will return -1 and errno will contain ECONNRESET, EPIPE
or similar... and disable beforehand SIGPIPE...

> I am having troublee determining if a socket is still connected to the
> remote host before I make a call to send().

> I know how to determine this in my code that makes the call to read(),
> ie check if read() returns 0, but the code that does the read() does not
> have access to certain variables I need to unset when the socket has
> been terminated by the other side.

> What I need to be able to do is to simply determine if a socket is still
> connected to it's remote host without using a read() call, as the read
> code is being done elsewhere and I don't want to mess up the actual
> read()) call.

> -shane


 
 
 

1. determining socket state without affecting its state.

I seem to have a socket fd leak somewhere in one of my applications
and I am having a hard time tracking down the sockets that have
"leaked".  the application uses a large number of sockets (the
system's hard-limit(*) minus 5) and sockets are constantly being
created and closed.

what is the best way to determine the status of a socket fd without
disturbing its state and without blocking?

(*) typically it uses 2445 sockets on IRIX and  251 sockets on Linux
    and SunOS.  each socket lives on average 3-5 seconds and is timed
    out (closed with close()) after 20 seconds.

-Bj?rn
--

 <URL:http://www.pvv.org/~borud/> | as damage and routes around it."
 UNIX person, one of "them"       |         - John Gilmore

2. PCI ports

3. send/recv socket calls

4. can't switch consoles (ctr-alt-fn#)

5. Understanding socket calls send() and recv()

6. How do I defeat mailtool's file locking?

7. Non-blocking sockets and recv/send system calls

8. Automating Solaris package installations

9. Need utility to trap network function calls (socket calls) and save to log file

10. Question: Problem with socket, socket system call returns 0

11. calling socket protocol family from another socket protocol family ?

12. : set state to XFRM_STATE_DEAD before calling xfrm_state_put in pfkey_msg2xfrm_state

13. 3rd CALL FOR ADDRESSES: Crypto/Security Companies AND State Report