Socket client

The Daytime Server application listens on a TCP port for incoming connections. In order to request the date and time, the Daytime Client must establish a client socket connection to the Daytime Server. It is hard to imagine a simpler TCP service than this—open a socket to the server and read data until the socket connection is closed. There is no additional requirement. Most of the networking examples in this book have focused on a higher-level protocol, HTTP, where the request and response are clearly defined with headers and a specific protocol to observe. In this example, the communications involve a lower-level socket connection, essentially raw, if you will, because there is no protocol associated with it beyond being a TCP stream (as opposed to UDP). Listing 13.12 demonstrates this lower-level socket communication.

0 0

Post a comment