Question

How can I check the status of remote end with the help of socket descriptor in vxworks. I am using TCP connection.

Was it helpful?

OTHER TIPS

VxWorks uses the BSD Sockets API. When the remote station has terminated a connection I/O functions such as read() and write() functions return an error status (-1 for read/write) and set errno.

On at least some BSD-derived stacks I have worked with, you can check whether the other end has closed using getpeername(). On supporting stacks this will return -1 and set ENOTCONN if the other end has closed its half of the connection.

This allows you to query whether the other end has called close() without having to make a socket read call. Contrary to what has been previously stated, it is possible to find this out from the IP stack without initiating some connection to the other end, because the IP stack receives a FIN notification when the other end closes its half of the connection. This information can then be used by the stack to notify future getpeername() callers that the other end has closed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top