linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: Francois Grieu <fgrieu@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Finding how much data is available for read from a SOCK_SEQPACKET
Date: Wed, 25 Mar 2009 15:05:07 +0000	[thread overview]
Message-ID: <18890.18467.865404.614181@cerise.gclements.plus.com> (raw)
In-Reply-To: <C5EFBA45.17C2D%fgrieu@gmail.com>


Francois Grieu wrote:

> I have a working program that receives blocks of data from a
> SOCK_SEQPACKET using a blocking read(). So far I use a
> fixed-size buffer of the maximum size.
> 
> I would like to query for the size available, malloc a block
> of the appropriate size, then read. Is that feasible?

It doesn't look like it. Unfortunately, ioctl(SIOCINQ) returns the
total number of bytes in all queued incoming packets, not the next
packet.

You could malloc() a maximum size packet then realloc() it once you've
received the data.

-- 
Glynn Clements <glynn@gclements.plus.com>

      reply	other threads:[~2009-03-25 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25  9:39 Finding how much data is available for read from a SOCK_SEQPACKET Francois Grieu
2009-03-25 15:05 ` Glynn Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18890.18467.865404.614181@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=fgrieu@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).