Derek Fountain <fountai@hursley.ibm.com> wrote:
There's a file called /dev/log which is a socket:
ls -l /dev/log srw-rw-rw- 1 root root 0 May 4 11:11 /dev/log
How do I create such a file?
Processes can create Unix sockets using the socket() and bind() system calls. An implementation in C can look like this: #include <sys/socket.h> #include <sys/un.h> #include <stdio.h> int main (int argc, char* argv[]) { int sockfd; struct sockaddr_un addr; addr.sun_family = AF_UNIX; strcpy (addr.sun_path, argv[1]); /* Beware of buffer overflows! */ if ((sockfd = socket (PF_UNIX, SOCK_STREAM, 0)) == -1) { perror ("socket"); exit (1); } if (bind (sockfd, (struct sockaddr*) &addr, sizeof (addr)) == -1) { perror ("bind"); exit (1); } ... } This example program will create a Unix socket with the name given as the first command line argument. Remember to remove the socket with unlink() if it is no longer needed. See `man 7 unix` for more information. Eilert -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Eilert Brinkmann -- Universitaet Bremen -- FB 3, Informatik eilert@informatik.uni-bremen.de - eilert@tzi.org - eilert@linuxfreak.com http://www.informatik.uni-bremen.de/~eilert/ -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
participants (1)
-
eilert@Informatik.Uni-Bremen.DE