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...

Match the following parts of the File Explorer interface with their function:

I. Address bar II. Content pane III. Details pane IV. Navigation pane V. Toolbar A. shows currently selected folder or library B. shows properties associated with a selected file C. includes buttons relevant to currently selected item D. contains Favorites, Libraries, Homegroup, Computer, and Network E. navigate to other folders or libraries

Computer Science & Information Technology

The definition of a C-string automatically involves a pointer.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A problem that results from incorrectly written code is known as a bug.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Describe how you can straighten out an unstructured flowchart segment.

What will be an ideal response?

Computer Science & Information Technology