Java Networking

At the core of Java's networking support is the thought of a socket. A socket identifies an endpoint in a network. The socket model was part of the 4.2BSD Berkeley UNIX release in the early 1980s. Because of this, the term Berkeley socket can also used.

Sockets

Sockets are at the foundation of modern networking because a socket allows a single computer to server many different clients at once, as well as to server many different types of information. This is accomplished through the use of a port, which is numbered socket on a particular machine. A server process is said to "listen" to a port before a client connects to it.

Server

A server is granted to accept multiple clients connected to the same port number, although each session is unique. To manage multiple clients connection, a server process must be multithreaded or have some other signifies of multiplexing the simultaneous I/O.

Socket Communication

Socket communication takes place via a protocol.

Protocol

Here are the three levels of protocols:

Let's discuss briefly about these three levels of protocol one by one.

Internet Protocol (IP)

Internet Protocol (IP) is a low-level routing protocol which breaks data into small packets and sends them to an address across a network, which doesn't guarantee to deliver the said packets to the destination.

Transmission Control Protocol (TCP)

Transmission Control Protocol (TCP) is a higher-level protocol which manages to robustly string together these packets, sorting and retransmitting them as necessary to dependably transmit data.

User Datagram Protocol (UDP)

A third protocol named User Datagram Protocol (UDP), sits next to TCP and can be used directly to support fast, connection-less, undependable transport of packets.

Port

Once a connection has be established, a higher-level protocol ensures, which is dependent on which port you are using. TCP/IP reserves the lower 1,024 ports for specific protocols. Many of these will seem known to you if you have spent any time surfing the Internet. Port number

and the list goes on. It is up to each protocol to specify how a client should interact with the port.

For instance, HTTP is the protocol that web browsers and servers use to transfer hypertext pages and images. It is just simple protocol for a basic page-browsing web server.

Here is how it works:
When a client requests a file from an HTTP server, an action known as a hit, it just sends the name of the file in a special format to a predefined port and reads back the file's contents. The server also responds with a status code to tell the client whether or not the request can be achieved and why.

Internet Address - IPv4

A key component of the Internet is the address. Every computer on the Internet has one. An Internet address is simply a number that uniquely identifies each computer on the Net. Originally, all the Internet address consisted of 32-bit values that organized as four 8-bit values. This address type was specified by IPv4 (Internet Protocol, version 4).

Internet Address - IPv6

On the other hand, a new addressing scheme, called IPv6 (Internet Protocol, version 6) has come into play. The IPv6 uses a 128-bit value to represent an address that organized into eight 16-bit chunks

Although there are several reasons for advantages to IPv6, the main one is that it supports a much larger address space than does IPv4. Fortunately, when using Java, you won't generally need to worry about whether IPv4 or IPv6 addresses are used as Java handles the details for you.

Just as the number of an IP address describes a network hierarchy, and the name of an Internet address, called its domain name, descries a machine's location in a name space. For instance, fresherearth.com is in the COM top-level domain (that reserved for the U.S. commercial sites); it is called fresherearth, and www determines the server for web requests. And an Internet domain name is simply mapped to an IP address by Domain Naming Service (DNS). This enables users to work with the domain names, but the Internet operates on IP address.

Java Online Test


« Previous Tutorial Next Tutorial »