On Tue, 2007-08-14 at 12:06 +0530, Diluka Moratuwage wrote:
Hi,
Can I configure the syslog-ng, so that, it writes only line by line. Now few lines at the same time. I mean, I wanna, write one line, and then another, not as a a bunch of lines. What I actually need to do, is reading one line, process it and do some things, and then listen to next line and so on. I highly appreciate if you can provide me information, on how to do this.
I'm not sure I understand what you are trying to achieve here. You have to handle your incoming connection as a "stream" and perform appropriate input buffering. There's nothing that'd ensure that two blocks sent by syslog-ng will be received as two blocks by your program. This is not how TCP or SOCK_STREAM sockets work. Use an input buffer, read in a chunk of bytes and iterate over all complete lines in your input buffer. If there's only a partial line left, read again. The maximum line length will be limited by the size of your input buffer. You might be able to use stdio and its buffering if you want to avoid implementing input side buffering on your own. (e.g. fdopen() the socket fd and then use fgets() to read complete lines) -- Bazsi