bind() to /dev/log failed

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

 




Hello All, 

I want to listen to /dev/log. For that I am using the following code. 

Please let me know whats the issue in the following code snip. Code I am running with root user. 

Thanks, wasim 

if ((sockfd = socket(AF_UNIX,SOCK_STREAM, 0)) == -1)
{
   printf("Failed To open AF_UNIX Socket");
   return -1;
} 
sunx.sun_family = AF_UNIX;
strncpy(sunx.sun_path, PR_PATH_LOG, sizeof(sunx.sun_path));
/*if (connect(sockfd, &syslog_addr, sizeof(syslog_addr)) == -1) {    //Connect call goes successful, But after that I am not able to recv any data.*/
 if (bind(sockfd, (struct sockaddr *) &sunx,sizeof(sunx.sun_family)+strlen(sunx.sun_path)) < 0) { /* bind fails saying 98 : Address already in use Even if I kill syslogd*/
	printf("Connect failed with the errno %s %d : %s\n",PR_PATH_LOG, errno,strerror(errno));
	close(sockfd);
}

if(recv( sockfd, (void *) buff, 1024,0) <=0) /* recv never come out if I use connect even after I do logger */
{
      printf("Error in recv call... errno = %d : %s : %s\n", errno, strerror(errno),buff);
      break;
}
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux