An example that shows how to send a file descriptor to a client over librpc connection.
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
{
int fd;
return (NULL);
}
printf("Received fd %d\n", fd);
dprintf(fd, "Hello there\n");
dprintf(fd, "I am writing to the pipe\n");
sleep(1);
dprintf(fd, "And sometimes sleeping\n");
dprintf(fd, "Bye.\n");
close(fd);
return (NULL);
}
int
main(int argc, const char *argv[])
{
(void)argc;
(void)argv;
write_to_pipe);
pause();
}