Re: Do I redirect stdout to opened socket?



On 2005-12-29, thisrule@xxxxxxxxx <thisrule@xxxxxxxxx> wrote:
[...]
> Then, write( 1, "message\n", 8 ) works good.
> The string, "message" displayed in the client program.
> But printf( "message\n" ) does not work.

It does work. But printf and friends are using buffered output. In
other words they store whatever they get in the buffer and send it only
when the buffer is full (kind of). There are different ways to control the
buffering behaviour on streams. In the simplest case you can call
fflush(stdout) to force writing of the data immidiately. Alternatevely
you can use setvbuf function to make your stdout stream unbuffered.
Actually this applies to stderr and any other stream (type FILE*).

--
Minds, like parachutes, function best when open
.



Relevant Pages

  • Re: Library Design, f0dders nightmare.
    ... Using printf was unfortunate, but in a way it demonstrates an important ... mention the internal buffer limit in the 'printf' documentation). ... you use the algo in a later OS but where it was designed to be used, ... break from a fixed GetCL would be ones *depending* on the buffer overflow. ...
    (alt.lang.asm)
  • Re: query about printf
    ... implementation of printf() that used a static internal buffer to build ... The buffer needn't be static; ... ever asynchronous events there could be) and the handler ... printfalso could call malloc() and when, ...
    (comp.lang.c)
  • Re: query about printf
    ... implementation of printfthat used a static internal buffer to build ... enough to doom re-entrancy. ... interrupting activity need to deposit characters in it, ... be done uninterruptably, printf() is non-reentrant. ...
    (comp.lang.c)
  • Re: Uses of setvbuf()
    ... buffer over an automatically allocated one? ... when I call setvbuf() it is to turn off buffering for stdin ... The setvbuf function may be used only after the stream pointed to by ...
    (comp.lang.c)
  • Re: defining a custom output facility
    ... when you tell the stream object to use a different stream ... buffer, you get a hold on the stream buffer actually used by the ... >> grasp at the string printf produces internally before printf sends ... If you need to retarget the output, you add the retargeting by ...
    (comp.lang.cpp)