Java Programming/Networking/Basics

From Wikibooks, open books for an open world
Jump to: navigation, search

Networking is the act of connecting two or more computers together so that they can communicate. Each computer has an address, known as an IP Address which they use to find the other computers on the network. Each computer also has a set of ports where each message is placed. Think of it as a post office. The post office is the computer. Each piece of mail, or packet in the computing world, is sorted out into a PO box, which would be analogous to a port. Imagine if there was only one box. Everyone would have a tough time getting to their mail! In this way, the data keeps from getting lost or overwritten by other data.

Unlike a post office, each port on a computer is used for different things. Port 80, for example, is the port for web browsing, and port 25 is the port for SMTP e-mail.

In the grand scheme of things, though, direct computer-to-computer conversing almost never happens. Most of the conversing is between a server and a client.

A server is just like a matre'd at a fancy restaurant. The client asks for a file that the server has, and the server brings it to the client.

In this chapter we are going to make both- both a server for files and a client for files.