Re: Finding how much data is available for read from a SOCK_SEQPACKET

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux