[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qmail
Subject:    Re: preferred way to read from from file descriptor 6 in ucspi
From:       "Matthew R. Dempsky" <mrd () alkemio ! org>
Date:       2007-04-11 14:13:20
Message-ID: 20070411141320.GB23605 () odin ! dempsky ! org
[Download RAW message or body]

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 list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic