* Finding how much data is available for read from a SOCK_SEQPACKET
@ 2009-03-25 9:39 Francois Grieu
2009-03-25 15:05 ` Glynn Clements
0 siblings, 1 reply; 2+ messages in thread
From: Francois Grieu @ 2009-03-25 9:39 UTC (permalink / raw)
To: linux-c-programming
Hello,
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?
Note: I think that I can not put the size at the head of the
packet since
" SOCK_SEQPACKET
Provides a sequenced, reliable, two-way connection-based
data transmission path for datagrams of fixed maximum length;
a consumer is required to read an entire packet with each
read system call."
TIA,
Francois Grieu
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Finding how much data is available for read from a SOCK_SEQPACKET
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
0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2009-03-25 15:05 UTC (permalink / raw)
To: Francois Grieu; +Cc: linux-c-programming
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-25 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).