From dev-return-7768-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Tue Aug 20 17:50:30 2002 Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 49544 invoked by uid 500); 20 Aug 2002 17:50:30 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 49533 invoked from network); 20 Aug 2002 17:50:29 -0000 Date: Wed, 21 Aug 2002 01:48:08 +0800 Mime-Version: 1.0 (Apple Message framework v482) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: apr_socket connection status check From: C K Tan To: dev@apr.apache.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.482) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I am looking for a way to check if a socket is still connected to the client. What is a good way to do this in APR? Here are some tries which do not work (on Win32 with the cvs co latest): 1) send 0 bytes -- failed to detect connection loss, probably due to buffering: int n = 0; int e = apr_send(sock, (char*) NULL, &n); if (e) not_connected(); 2) recv 0 bytes -- blocked in definitely: int n = 0; int e = apr_recv(sock, (char*) NULL, &n); if (e) not_connected(); 3) query APR_SO_DISCONNECTED -- always return connection OK: int n, e; e = apr_socket_opt_get(sock, APR_SO_DISCONNECTED, &n); if (e || n) not_connected(); Thanks, -cktan