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 ...
Get Just Java™ 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.