Advanced Programming in the UNIX® Environment
ptg10805159 Section 17.4 Passing File Descriptors 647 To receive a descriptor (Figure17.14), we allocate enough room for acmsghd ...
ptg10805159 648 Advanced IPC Chapter 17 for (ptr = buf; ptr < &buf[nr]; ) { if (*ptr++ == 0) { if (ptr != &buf[nr-1]) ...
ptg10805159 Section 17.4 Passing File Descriptors 649 When we transmit credentials, we need to reserve space only for the cmsgcr ...
ptg10805159 650 Advanced IPC Chapter 17 msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_flags = 0; if (fd_to_send < 0) { ms ...
ptg10805159 Section 17.4 Passing File Descriptors 651 #define CREDSTRUCT ucred #define CR_UID uid #define CREDOPT SO_PASSCRED #d ...
ptg10805159 652 Advanced IPC Chapter 17 err_ret("recvmsg error"); return(-1); }else if (nr == 0) { err_ret("connection closed by ...
ptg10805159 Section 17.5 An Open Server,Version 1 653 17.5 An Open Server,Version 1 Using file descriptor passing, we now develo ...
ptg10805159 654 Advanced IPC Chapter 17 Themainfunction (Figure17.18) is a loop that reads a pathname from standard input and co ...
ptg10805159 Section 17.5 An Open Server,Version 1 655 char buf[10]; struct iovec iov[3]; static int fd[2] = { -1, -1 }; if (fd[0 ...
ptg10805159 656 Advanced IPC Chapter 17 Now let’s look at the open server.It is the programopendthat is executed by the client i ...
ptg10805159 Section 17.5 An Open Server,Version 1 657 #include "opend.h" #include <fcntl.h> void handle_request(char *buf, ...
ptg10805159 658 Advanced IPC Chapter 17 char *ptr, *argv[MAXARGC]; int argc; if (strtok(buf, WHITE) == NULL) /* an argv[0] is re ...
ptg10805159 Section 17.6 An Open Server,Version 2 659 17.6 An Open Server,Version 2 In the previous section, we developed an ope ...
ptg10805159 660 Advanced IPC Chapter 17 if (writev(csfd, &iov[0], 3) != len) { err_ret("writev error"); return(-1); } /* rea ...
ptg10805159 Section 17.6 An Open Server,Version 2 661 { int i; if (client == NULL) client = malloc(NALLOC * sizeof(Client)); els ...
ptg10805159 662 Advanced IPC Chapter 17 return; } } log_quit("can’t find client entry for fd %d", fd); } Figure 17.27Functions t ...
ptg10805159 Section 17.6 An Open Server,Version 2 663 Theargcandargvarguments arethe same ones passed to themainfunction of the ...
ptg10805159 664 Advanced IPC Chapter 17 Client *client=NULL; int main(int argc, char *argv[]) { int c; log_open("open.serv", LOG ...
ptg10805159 Section 17.6 An Open Server,Version 2 665 for ( ; ; ) { rset = allset; /* rset gets modified each time around */ if ...
ptg10805159 666 Advanced IPC Chapter 17 argument toselect.Wealso keep track of the highest index in use in the clientarray.) An ...
«
30
31
32
33
34
35
36
37
38
39
»
Free download pdf