The JavaTM Tutorial
Previous Page Trail Contents Next Page Start of Tutorial Search

Trail: Custom Networking


Your feedback is important to us! If you have comments about this trail, you can send us mail about it by filling out the form on our feedback page.
The Java platform is highly regarded in part because of its suitability for writing programs that use and interact with the resources on the Internet and the World Wide Web. In fact, Java-compatible browsers use this ability of the Java platform to the extreme to transport and run applets over the Internet.

This trail walks you through the complexities of writing Java applications and applets that can be used on the Internet.

Overview of Networking has two sections. The first describes the networking capabilities of the Java platform that you may already be using without realizing that you are using the network. The second provides a brief overview of networking to familiarize you with terms and concepts that you should understand before reading how to use URLs, sockets, and datagrams.

Working with URLs discusses how your Java programs can use URLs to access information on the Internet. A URL (Uniform Resource Locator) is the address of a resource on the Internet. Your Java programs can use URLs to connect to and retrieve information over a network. This lesson provides a more complete definition of a URL and shows you how to create and parse a URL, how to open a connection to a URL, and how to read from and write to that connection.

All About Sockets explains how to use sockets so that your programs can communicate with other programs on the network. A socket is one endpoint of a two-way communication link between two programs running on the network. This lesson shows you how a client can connect to a standard server, the Echo server, and communicate with it via a socket. It then walks you through the details of a complete client/server example, which shows you how to implement both the client side and the server side of a client/server pair.

All About Datagrams takes you step by step through a simple client/server example that uses datagrams to communicate. It then challenges you to rewrite the example using multicast socket instead.


Security considerations: Note that communications over the network are subject to approval by the current security manager. Providing Your Own Security Manager(in the Custom Networking trail) describes what a security manager is and how to write a customized security manager for your applications. For general information about the security features provided by the JDK, refer to Security in Java 2 SDK 1.2(in the Custom Networking trail).

The example programs in the following lessons that cover URLs, sockets, and datagrams are standalone applications, which, by default, have no security manager. If you convert these applications to applets, they may be unable to communicate over the network, depending on the browser or viewer in which they are running. See Practical Considerations when Writing Applets(in the Custom Networking trail) for information about the security restrictions placed on applets.



Previous Page Trail Contents Next Page Start of Tutorial Search