Advanced Programming in the UNIX® Environment
ptg10805159 Section 16.4 Connection Establishment 607 There is a problem with the code shown in Figure16.10: it isn’t portable. ...
ptg10805159 608 Network IPC: Sockets Chapter 16 If the socket descriptor is in nonblocking mode, which we discuss further in Sec ...
ptg10805159 Section 16.4 Connection Establishment 609 If no connect requests arepending,acceptwill block until one arrives. Ifso ...
ptg10805159 610 Network IPC: Sockets Chapter 16 16.5 DataTr ansfer Since a socket endpoint is represented as a file descriptor,w ...
ptg10805159 Section 16.5 Data Transfer 611 the destination address is first set by callingconnect,sosendtogives us an alternate ...
ptg10805159 612 Network IPC: Sockets Chapter 16 Therecvfunction is similar toread,but allows us to specify some options to contr ...
ptg10805159 Section 16.5 Data Transfer 613 If we areinterested in the identity of the sender,wecan userecvfromto obtain the sour ...
ptg10805159 614 Network IPC: Sockets Chapter 16 Example — Connection-Oriented Client Figure16.16 shows a client command that com ...
ptg10805159 Section 16.5 Data Transfer 615 err_exit(err, "can’t connect to %s", argv[1]); } Figure 16.16 Client command to get u ...
ptg10805159 616 Network IPC: Sockets Chapter 16 sprintf(buf, "error: %s\n", strerror(errno)); send(clfd, buf, strlen(buf), 0); } ...
ptg10805159 Section 16.5 Data Transfer 617 To find its address, the server needs to get the name of the host on which it is runn ...
ptg10805159 618 Network IPC: Sockets Chapter 16 exit(1); } if ((pid = fork()) < 0) { syslog(LOG_ERR, "ruptimed: fork error: % ...
ptg10805159 Section 16.5 Data Transfer 619 hint.ai_addr = NULL; hint.ai_next = NULL; if ((err = getaddrinfo(host, "ruptime", &am ...
ptg10805159 620 Network IPC: Sockets Chapter 16 The other choice we have is to deal with the error by letting the user retry the ...
ptg10805159 Section 16.5 Data Transfer 621 int sockfd, err; struct sigaction sa; if (argc != 2) err_quit("usage: ruptime hostnam ...
ptg10805159 622 Network IPC: Sockets Chapter 16 Example — Connectionless Ser ver The program in Figure16.20 is the datagram vers ...
ptg10805159 Section 16.6 Socket Options 623 if (argc != 1) err_quit("usage: ruptimed"); if ((n = sysconf(_SC_HOST_NAME_MAX)) < ...
ptg10805159 624 Network IPC: Sockets Chapter 16 We can set a socket option with thesetsockoptfunction. #include <sys/socket.h ...
ptg10805159 Section 16.6 Socket Options 625 Thelenpargument is a pointer to an integer.Beforecallinggetsockopt, we set the integ ...
ptg10805159 626 Network IPC: Sockets Chapter 16 16.7 Out-of-Band Data Out-of-band data is an optional featuresupported by some c ...
«
28
29
30
31
32
33
34
35
36
37
»
Free download pdf