Re: cat problem

From: Weiguang Shi (wgshi_at_namao.cs.ualberta.ca)
Date: 11/07/04


Date: Sun, 7 Nov 2004 19:46:20 +0000 (UTC)

Barry Margolin wrote:
>
>It *does* block. But when read() blocks, it will return as soon as any
>data is available, it doesn't wait for the buffer to fill up. The
>buffer size is just a maximum, not necessarily the expected size of the
>message. Just because you use a buffer that's 1KB doesn't mean you
>actually expect that much data, you just want to allow for it in case it
>comes.

That's right: blocking doesn't equal to filling.

Thanks.
Weiguang



Relevant Pages

  • Re: socket: recv(MSG_PEEK) or select()
    ... Barry Margolin wrote: ... I think another difference would be that the peek might tell you if ... I'd probably just go ahead and read from the socket, and buffer ...
    (comp.unix.questions)
  • Re: SOCK_DGRAM atomicity vs SOCK_STREAM reliability for unix domain
    ... Ulrich Hobelmann wrote: ... > Barry Margolin wrote: ... >> But you don't always have to do multiple system calls. ... >> buffer large enough for most common messages, ...
    (comp.unix.programmer)
  • Re: client-server using named pipes
    ... we read the message from the client into a buffer. ... of reading to a buffer, i want to read the message directly into the ... Barry Margolin, barmar@xxxxxxxxxxxx ...
    (comp.unix.programmer)
  • Re: point to point confusion
    ... when to use what modes of both blocking and non blocking com? ... > Only if there is enough unused buffer space. ... > there is no buffer space for the message and a matching receive has not ...
    (comp.parallel.mpi)
  • Re: Integer to "string" conversions
    ... because of the win/win of not having to marshal data into a temporary buffer ... to buffer this out at the page size or twice the page size. ... the blocking problem was to use pthreads. ... socket routines, let me know - but I highly recommend writing your own first ...
    (comp.lang.c)