[syslog-ng] My server that listens to Syslog-ng
Diluka Moratuwage
diluka at wso2.com
Sun Aug 12 06:25:54 CEST 2007
Sorry missed the code snippet. Here it is.
new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
printf("Accepted a client...\n");
while((len = recv (new_fd, buffer, BUFF_SIZE - 1, MSG_PEEK)) > 0)
{
read = recv(new_fd, buffer, BUFF_SIZE - 1, 0);
buffer[read] = '\0';
tmp_buffer = (char*)malloc((strlen(big_buffer) + read + 1) *
sizeof(char));
memset(tmp_buffer, 0, sizeof(char) * (strlen(big_buffer) + 1 +
read));
memcpy(tmp_buffer, big_buffer, strlen(big_buffer) * sizeof(char));
memcpy(tmp_buffer + strlen(big_buffer), buffer, sizeof(char) *
read);
tmp_buffer[strlen(tmp_buffer)] = '\0';
free(big_buffer);
big_buffer = tmp_buffer;
tmp_buffer = NULL;
memset(buffer, 0, BUFF_SIZE * sizeof(char));
printf(big_buffer);
}
Diluka Moratuwage wrote:
> Hi,
>
> I wrote a program which listens to a port (5001), which the
> syslog-ng was
> configured to write to. Everything works fine, but sometimes I get msgs
> like,
>
> <43>Aug 11 19:39:03 diluka-laptop syslog-ng[5084]: Connection broken;
> time_reopen='10'
> <43>Aug 11 19:39:13 diluka-laptop syslog-ng[5084]: EOF occurred while
> idle; fd='20'
>
> Can anybody pls let me know what my mistake would be ??? Following
> is the code snippet
> shows how I read from the syslog-ng. I think there is a problem, in the
> way I read from the
> syslog-ng. Pls correct me, if I have missed any points. I really
> appreciate if you can provide
> me some help in getting through the problem.
>
> Thanks,
> Diluka.
>
>
>
>
>
> _______________________________________________
> syslog-ng maillist - syslog-ng at lists.balabit.hu
> https://lists.balabit.hu/mailman/listinfo/syslog-ng
> Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
>
>
>
More information about the syslog-ng
mailing list