Exercises
121. | Use WSAStartup to determine the highest and lowest Winsock version numbers supported on the systems accessible to you. |
122. | Use the JobShell program from Chapter 6 to start the server and several clients, where each client is created using the "detached" option. Eventually, shut down the server by sending a console control event through the kill command. Can you suggest any improvements in the serverSK shutdown logic? |
123. | Modify the client and server programs (Program 12-1 and 12-2) so that they use datagrams to locate a server. The mailslot solution in Chapter 11 could be used as a starting point. |
124. | Modify the named pipe server in Chapter 11 (Program 11-3) so that it creates threads on demand instead of a server thread pool. Rather than predefining a fixed maximum for the number of named pipe instances, allow the system to determine the maximum. |
125. | Perform experiments to determine whether in-process servers are faster than out-of-process servers. For example, you can use the word count example (Program 12-3); there is an executable wc program as well as the DLL function shown in Program 12-3. |
126. | The number of clients that serverSK can support is bounded by the array of server thread arguments. Modify the program so that there is no such bound. You will need to create a data structure that allows you to add and delete thread arguments, and you also need to be able to scan the structure for terminated server threads. |
127. | Develop additional in-process servers. For example, convert the grep program (see Chapter 6). |
128. | Enhance the server (Program 12-2) so that you can specify multiple DLLs on the command line. If the DLLs do not all fit into memory, develop a strategy for loading and unloading them. |
129. | Investigate the setsockopt function and the SO_LINGER option. Apply the option to one of the server examples. |
1210. | Use the scatter/gather feature of Windows Sockets 2.0 to simplify the message sending and receiving functions in Program 12-1 and 12-2. |
1211. | Ensure that serverSK is free of resource leaks (see Exercise 11-8 for more explanation). Do the same with serverSKST, which was modified to use the DLL in Program 12-4. |
1212. | Extend the exception handler in Program 12-3 so that it reports the exception and exception type at the end of the temporary file used for the server results. |
1213. | Extended exercise (requires extra equipment): If you have access to a UNIX system that is networked to your Windows system, port clientSK to the UNIX system and have it access serverSK to run Windows programs. You will, of course, need to convert data types such as DWORD and SOCKET to other types (unsigned int and int, respectively, in these two cases). Also, you will need to ensure that the message length is transmitted in big-endian format. Use functions such as htonl to convert the message lengths. Finally, port serverSK to UNIX so that Windows systems can execute UNIX commands. Convert the DLL calls to shared library calls. |
1214. | Read about the Secure Sockets Layer (SSL) in MSDN and the Additional Reading references. Enhance the programs to use SSL for secure client/server communication. |