[haiku-development] Re: server connection

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 23 Nov 2010 17:49:04 +0100

On 2010-11-23 at 17:15:02 [+0100], Donn Cave <donn@xxxxxxxxxxx> wrote:
> Quoth Ingo Weinhold <ingo_weinhold@xxxxxx>,
> ...
> > Not from these function. However there's the FIONREAD ioctl() to get the
> > number of bytes ready for reading. For a stream socket there's mostly no
> > point in retrieving that information, though. Usually one expects a 
> > certain
> > (or minimum) amount of data and one simply iteratively reads until one has
> > got that much. poll(), select() or the haikuish wait_for_objects() are 
> > only
> > needed, if the thread needs to deal with multiple FDs (/events). If that's
> > not necessary, then just use recv()/send() in blocking mode.
> 
> If he insists on using the IDLE feature, the client will be waiting
> for unsolicited I/O, like a server, so he may need wait_for_objects()
> in order to respond to application message events as well.

That's what I was saying. :-) Often the only other event an explicit receiver 
thread has to react to is the termination of the connection (or application), 
though. Closing the socket accomplishes that without any extra provision, so 
a blocking recv() should do just fine in such a case.

> With SSL, I suppose one would have to be careful to check for pending
> data in the SSL buffer before calling wait_for_objects.

I don't recall any of the OpenSSL API, so things might indeed be more 
complicated in this case.

CU, Ingo

Other related posts: