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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux