Ports and Protocols
As we saw in Chapter 25, you use input and output streams on sockets just as though you were reading/writing a file. The class java.net.ServerSocket lets your server program accept incoming data by spawning off a thread with a socket that you can read client requests from. The class java.net.Socket lets you send data to a server socket on another computer, or read response data that is coming back into the local host.
Servlets are a higher-level alternative to reading/writing sockets. Servlets can be used to service any request that is made via a socket (such as FTP), not just web page requests via HTTP. A servlet that talks something other than HTTP is called a “generic servlet” and it will extend the class javax.servlet.GenericServlet ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access