Qmail
[Top] [All Lists]

Re: preferred way to read from from file descriptor 6 in ucspi

To: qmail@list.cr.yp.to
Subject: Re: preferred way to read from from file descriptor 6 in ucspi
From: "Matthew R. Dempsky" <mrd@alkemio.org>
Date: Wed, 11 Apr 2007 09:13:20 -0500
Delivered-to: sp-com-lists@consult.net
Delivered-to: gmail-qmail@securepoint.com
Delivered-to: sp.com.list@gmail.com
Delivered-to: mailing list qmail@list.cr.yp.to
In-reply-to: <20070411073938.6822.qmail@rahul.net>
Mail-followup-to: qmail@list.cr.yp.to
Mailing-list: contact qmail-help@list.cr.yp.to; run by ezmlm
References: <20070411073938.6822.qmail@rahul.net>
On Wed, Apr 11, 2007 at 12:39:38AM -0700, John Conover wrote:
>     while ((cnt = read (6, buf, MAXBUF)) >= 0)

If read(2) returns 0, then the socket is closed.  Stop reading from
it.

Also, since you're using fd 6, I'll assume you're using tcpclient,
which leaves the socket with ndelay set (i.e., if there's no data
available, read(2) will return -1/EAGAIN).  You can use select(2) to
wait for data to become available or use fcntl(2) to disable ndelay.

<Prev in Thread] Current Thread [Next in Thread>