Is it possible to send a ?le descriptor using nonblocking I/O? If so, how do you know when the ?le descriptor has been received by the server?

What will be an ideal response?

es, it is possible to send a ?le descriptor if the socket is in nonblocking mode. To detect when the server actually receives (retrieves) the ?le descriptor, we can use a trick: the socket connection can buffer a ?xed amount of information. Because we need to send some data along with the ?le descriptor, we can send the maximum amount of data we can write without blocking. Then we can call either select(2) or poll(2) to detect when we can write to the socket again. The program shown in Figure 66 illustrates the solution. We call the getcapacity function to determine the largest message we can write to a connected UNIX domain stream socket. This varies by platform, and interestingly enough, requires that the socket be in nonblocking mode on BSD-based implementations. We include private versions of the library functions to send (Figure17.13) and receive (Figure17.14) a ?le descriptor over a UNIX domain socket so that we can use the proper buffer size. We use poll to detect when the stream becomes writable. This happens when the ?le descriptor is retrieved from the other end of the connection.

Computer Science & Information Technology

You might also like to view...

You can upgrade a CPU by adding registers and cache memory to it

Indicate whether the statement is true or false

Computer Science & Information Technology

A(n) ________ is an object, such as a label or text box, in a form or report that enables you to view or manipulate information stored in tables or queries

Fill in the blank(s) with correct word

Computer Science & Information Technology