Introduction to Networking in java

The Process of connecting two or more than two computer in order to share the resources like a printer, scanner, media etc is called Networking.

Java Provides us a number of built-in classes for networking , these classes are present in java.net package, with the help of these classes we are able to connect two computer to share the resouces.


Main component of Networking

Basically, there are two main component of networking these are :
1) Sender
2) Receiver

  Sender : The person who is sending the data is called sender .

  Receiver: The person who is receiving the data is called Receiver .

  In networking terminology, every one says Client and Server.

  Client : The person/system who is sending the request and taking the response is called client.

  Response: The person who is taking the request and sending the response is called Server.

Categories of network:

We are having two types of networks
1) Client-server network.
2) Peer-to-peer network.

  Client-server: In the client-server architecture, client system behaves as a client and server system behaves as a server.

  Peer-to-peer: In the peer to peer system, client sometimes behaves as a server, server system sometimes behaves like a client, the roles are not fixed.

Frequently used terms in the networking :

1) IP Address

2) URL(Uniform Resource Locator)

3) Protocol

4) Port Number

5) MAC address.

6) Connection-oriented and connectionless protocol

7) Socket.

1) IP Address

IP Address is a unique identification number given to the computer to identify it uniquely in the network.

The IP Address is uniquely assigned to the computer it is not duplicated. The IP Address range is 0-255 . We can identify the particular computer in the network with the help of IP Address.

The IP Address contains four digit number

a. 125.0.4.255----good
b. 1.2.3.4.5.6-------bad
Each and every website has its own IP Address . eg
Site Name:- www.google.com
IP Address :- 74.125.224.72

2) URL(Uniform Resource Locator)

By using the URL we are accessing some information present on the world wide web.
for example : https://www.google.com

3) Protocol

The protocol is a set of rules and regulations followed by the every computer present in the network, this is useful to send the data physically from one place to another place in the network.

  TCP(Transmission Control Protocol)(connection oriented protocol)

  UDP (User Data Gram Protocol)(connection less protocol)

  Telnet

  SMTP(Simple Mail Transfer Protocol)

  FTP(File Transfer Protocol)

  IP (Internet Protocol) and many more.

4) Port Number

The port number is used to uniquely identify different applications. It acts as a communication endpoint between applications.

The port number is associated with the IP address for communication between two applications.

Port number 0 to 1024 are already reserved for standard protocol such as SMTP, FTP, HTTP, Telnet etc

5) MAC address.

MAC (Media Access Control) Address is a unique identifier of NIC (Network Interface Controller). A network node can have multiple NIC but each with unique MAC.

6) Connection-oriented and Connection less protocol

In the connection-oriented protocol, acknowledgment is sent by the receiver. So it is reliable but slow. The example of a connection-oriented protocol is TCP.

But, in the connection-less protocol, acknowledgment is not sent by the receiver. So it is not reliable but fast. The example of a connection-less protocol is UDP.

7) Socket

A socket is an endpoint between two-way communication.

1) The socket is used to create the connection between the client and server.
2) The socket is nothing but a combination of IP Address and port number.
3) The socket is created on the client side.
4) Socket is class present in the java.net package
5) It is acting as a communicator between the client and server.
6) Whenever if we want to send the data first we have to create a socket that acts as a medium.