From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,189ab8c06b5bc83e,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-06-30 08:39:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stueberl.de!npeer.de.kpn-eurorings.net!newsfeed.kabelfoon.nl!195.129.110.21.MISMATCH!bnewsfeed00.bru.ops.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!news!not-for-mail From: "Bob" Newsgroups: comp.unix.tru64 Subject: Help checking a TCP/IP socket connection Date: Mon, 30 Jun 2003 16:39:01 +0100 Organization: Thales Message-ID: NNTP-Posting-Host: w1096.int.rdel.co.uk X-Trace: rdel.co.uk 1056987575 24703 172.26.71.242 (30 Jun 2003 15:39:35 GMT) X-Complaints-To: postmaster@uk.thalesgroup.com NNTP-Posting-Date: 30 Jun 2003 15:39:35 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.unix.tru64:10132 Hi, We have an in-house communication system running on Tru64 unix. It employs non-blocking TCP/IP sockets for IPC within a single host. We wish to test the connection between a pair of processes prior to attempting to send a message - a method called "isConnected()". Our current implementation of isConnected() follows these steps: 1. Attempt a recv() from the target with the MSG_PEEK flag set. 2. If recv() returns a value >0 we return true. 3. If recv() returns -1 and errno is set to EWOULDBLOCK we return true. 4. Otherwise we return false. We are frequently finding that both errno and the return value from recv() are 0. This suggests that the connection to the target has been lost. However, this would seem to incorrect as subsequent messages are sent correctly. Can anyone help understand the behaviour of recv() or suggest a better way of checking the connection. Many thanks Jeff