The term socket might sound a little strange, but sockets are the objects that let you communicate with the network. A socket doesn't represent a physical device, just an endpoint of a network connection. There are three main socket classes in Java—Socket, ServerSocket, and DatagramSocket. Of these, only the Socket and ServerSocket classes are used for connection-oriented data (that is, they support the TCP protocol). The DatagramSocket class does connectionless networking (the UDP protocol).
Remember from Chapter 26, "Networks and Network Protocols," that to create a TCP connection, you must first have a listener. The ServerSocket class lets you listen for incoming connections. You create a ServerSocket