#include #include #include #include #include #include #include int main() { int pipe_fd, send_size; struct sockaddr_un pipe_addr; socklen_t pipe_addrlen; char buf[100]; /* creating test unix domain socket pipe */ pipe_fd = socket(AF_UNIX, SOCK_DGRAM, 0); /* SOCK_DGRAM require this to bind */ bzero((char *)&pipe_addr, sizeof(pipe_addr)); /* fill in pipe_addr structire */ pipe_addr.sun_family = AF_UNIX; strncpy(pipe_addr.sun_path, "pipe.100", 10); pipe_addrlen = sizeof(pipe_addr.sun_family) + strlen(pipe_addr.sun_path) + 1; /* unlink old socket file */ unlink(pipe_addr.sun_path); /* bind socket to special file named pipe.100 in current directory */ bind(pipe_fd, (struct sockaddr *)&pipe_addr, pipe_addrlen); /* now we can try to send packet to pipe */ send_size = sendto(pipe_fd, buf, 100, 0, (struct sockaddr *)&pipe_addr, pipe_addrlen); if (send_size < 0) { printf("Can't send packet to pipe...\n"); printf("Problem: %s\n", strerror(errno)); } }