TCP Client Alternatives





TCP Client Alternatives

We have already examined various client designs, but it is worth summarizing their strengths and weaknesses:

  • Figure was the basic TCP client. There were two problems with this program. First, while it is blocked awaiting user input, it does not see network events such as the peer closing the connection. Additionally, it operates in a stop-and-wait mode, making it inefficient for batch processing.

  • Figure was the next iteration, and by using select, the client was notified of network events while waiting for user input. However, this program did not handle batch mode correctly. Figure corrected this problem by using the shutdown function.

  • Figure began the presentation of our client using nonblocking I/O.

  • The first of our clients that went beyond the single-process, single-thread design was Figure, which used fork with one process handling the client-to-server data and the other process handling the server-to-client data.

  • Figure used two threads instead of two processes.

At the end of Section 16.2, we summarized the timing differences between these various versions. As we noted there, although the nonblocking I/O version was the fastest, the code was more complex and using either two processes or two threads simplifies the code.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows