Skip to content

Commit df0b5ab

Browse files
Update README.md
1 parent 67a6e0e commit df0b5ab

1 file changed

Lines changed: 88 additions & 17 deletions

File tree

_moreReadMe/networking/README.md

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Java Networking is a concept of connecting two or more computing devices together so that we can share resources.
44

5+
When computing devices such as laptops, desktops, servers, smartphones, and tablets and an eternally-expanding arrangement of IoT gadgets such as cameras, door locks, doorbells, refrigerators, audio/visual systems, thermostats, and various sensors are sharing information and data with each other is known as networking.
6+
57
Java Socket Programming provides facility to share data between different computing devices.
68

79
**Advantage of Java Networking :**
@@ -13,33 +15,37 @@ Java Socket Programming provides facility to share data between different comput
1315
- **UDP:** User Datagram Protocol provides a connection-less protocol service by allowing packet of data to be transferred along two or more nodes
1416

1517

16-
## Java Networking Terminology :
18+
## Java Networking Terminology
1719

1820
Some of the widely used java networking terminologies are as follows:
1921

20-
1. IP Address
21-
- IP address is a unique number assigned to a node of a network e.g. 192.168.0.1. It is composed of octets that range from 0 to 255. It is a logical address that can be changed.
22+
**1. IP Address**
23+
- IP address is a unique number assigned to a node of a network e.g. 192.168.0.1. It is composed of octets that range from 0 to 255. It is a logical address that can be changed.
2224

23-
2. Protocol
24-
- A protocol is a set of rules basically that is followed for communication. For example: TCP, FTP, Telnet, SMTP, POP, etc.
25+
**2. Protocol**
26+
- A protocol is a set of rules basically that is followed for communication. For example: TCP, FTP, Telnet, SMTP, POP, etc.
2527

26-
3. Port Number
27-
- 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.
28+
**3. Port Number**
29+
- 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.
2830

29-
4. MAC Address
30-
- 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. The main difference between MAC and IP address is that, MAC Address is used to ensure the physical address of computer. It uniquely identifies the devices on a network. While IP address are used to uniquely identifies the connection of network with that device take part in a network.
31+
**4. MAC Address**
32+
- 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. The main difference between MAC and IP address is that, MAC Address is used to ensure the physical address of computer. It uniquely identifies the devices on a network. While IP address are used to uniquely identifies the connection of network with that device take part in a network.
3133

32-
5. Socket
33-
- A socket is an endpoint between two way communication. More details in "Socket" section below.
34+
**5. Socket**
35+
- A socket is one endpoint of a two-way communication connection between the two applications running on the network. The socket mechanism presents a method of inter-process communication (IPC) by setting named contact points between which the communication occurs. A socket is tied to a port number so that the TCP layer can recognize the application to which the data is intended to be sent.
3436

35-
6. Connection-oriented protocol
36-
- In connection-oriented protocol, acknowledgement is sent by the receiver. So, it is reliable but slow. The example of connection-oriented protocol is TCP.
37+
**6. Connection-oriented protocol**
38+
- In connection-oriented protocol, acknowledgement is sent by the receiver. So, it is reliable but slow. The example of connection-oriented protocol is TCP.
3739

38-
7. Connection-less protocol
39-
- In connection-less protocol, acknowledgement is not sent by the receiver. So, it is not reliable but fast. The example of connection-less protocol is UDP.
40+
**7. Connection-less protocol**
41+
- In connection-less protocol, acknowledgement is not sent by the receiver. So, it is not reliable but fast. The example of connection-less protocol is UDP.
42+
43+
44+
45+
46+
## Java Networking Classes
4047

41-
## java.net package
42-
The java.net package provides many classes to deal with networking applications in Java. A list of these classes is given below:
48+
The java.net package of the Java programming language includes various classes that provide an easy-to-use means to access network resources. The classes covered in the java.net package are given as follows –
4349

4450
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> |
4551
|-------------|-------------|-------------|-------------|-------------|
@@ -51,6 +57,68 @@ The java.net package provides many classes to deal with networking applications
5157
|SecureCacheResponse|ServerSocket|Socket|SocketAddress|SocketImpl|
5258
|SocketPermission|StandardSocketOptions|URI|URL|URLClassLoader|
5359
|URLConnection|URLDecoder|URLEncoder|URLStreamHandler|-|
60+
61+
**1. CacheRequest**
62+
- The CacheRequest class is used in java whenever there is a need to store resources in ResponseCache. The objects of this class provide an edge for the OutputStream object to store resource data into the cache.
63+
64+
**2. CookieHandler**
65+
- The CookieHandler class is used in Java to implement a callback mechanism for securing up an HTTP state management policy implementation inside the HTTP protocol handler. The HTTP state management mechanism specifies the mechanism of how to make HTTP requests and responses.
66+
67+
**3. CookieManager**
68+
- The CookieManager class is used to provide a precise implementation of CookieHandler. This class separates the storage of cookies from the policy surrounding accepting and rejecting cookies. A CookieManager comprises a CookieStore and a CookiePolicy.
69+
70+
**4. DatagramPacket**
71+
- The DatagramPacket class is used to provide a facility for the connectionless transfer of messages from one system to another. This class provides tools for the production of datagram packets for connectionless transmission applying the datagram socket class.
72+
73+
**5. InetAddress**
74+
- The InetAddress class is used to provide methods to get the IP address of any hostname. An IP address is expressed by a 32-bit or 128-bit unsigned number. InetAddress can handle both IPv4 and IPv6 addresses.
75+
76+
**6. Server Socket**
77+
- The ServerSocket class is used for implementing system-independent implementation of the server-side of a client/server Socket Connection. The constructor for ServerSocket class throws an exception if it can’t listen on the specified port. For example – it will throw an exception if the port is already being used.
78+
79+
**7. Socket**
80+
- The Socket class is used to create socket objects that help the users in implementing all fundamental socket operations. The users can implement various networking actions such as sending, reading data, and closing connections. Each Socket object built using java.net.Socket class has been connected exactly with 1 remote host; for connecting to another host, a user must create a new socket object.
81+
82+
**8. DatagramSocket**
83+
- The DatagramSocket class is a network socket that provides a connection-less point for sending and receiving packets. Every packet sent from a datagram socket is individually routed and delivered. It can further be practiced for transmitting and accepting broadcast information. Datagram Sockets is Java’s mechanism for providing network communication via UDP instead of TCP.
84+
85+
**9. Proxy**
86+
- A proxy is a changeless object and a kind of tool or method or program or system, which serves to preserve the data of its users and computers. It behaves like a wall between computers and internet users. A Proxy Object represents the Proxy settings to be applied with a connection.
87+
88+
**10. URL**
89+
- The URL class in Java is the entry point to any available sources on the internet. A Class URL describes a Uniform Resource Locator, which is a signal to a “resource” on the World Wide Web. A source can denote a simple file or directory, or it can indicate a more difficult object, such as a query to a database or a search engine.
90+
91+
**11. URLConnection**
92+
- The URLConnection class in Java is an abstract class describing a connection of a resource as defined by a similar URL. The URLConnection class is used for assisting two distinct yet interrelated purposes. Firstly it provides control on interaction with a server(especially an HTTP server) than a URL class. Furthermore, with a URLConnection, a user can verify the header transferred by the server and can react consequently. A user can also configure header fields used in client requests using URLConnection.
93+
94+
95+
96+
97+
## Java Networking Interfaces
98+
99+
The java.net package includes various interfaces also that provide an easy-to-use means to access network resources. The interfaces included in the java.net package are as follows –
100+
101+
**1. CookiePolicy**
102+
- The CookiePolicy interface in the java.net package provides the classes for implementing various networking applications. It decides which cookies should be accepted and which should be rejected. In CookiePolicy, there are three pre-defined policy implementations, namely ACCEPT_ALL, ACCEPT_NONE, and ACCEPT_ORIGINAL_SERVER.
103+
104+
**2. CookieStore**
105+
- A CookieStore is an interface that describes a storage space for cookies. CookieManager combines the cookies to the CookieStore for each HTTP response and recovers cookies from the CookieStore for each HTTP request.
106+
107+
**3. FileNameMap**
108+
- The FileNameMap interface is an uncomplicated interface that implements a tool to outline a file name and a MIME type string. FileNameMap charges a filename map ( known as a mimetable) from a data file.
109+
110+
**4. SocketOption**
111+
- The SocketOption interface helps the users to control the behavior of sockets. Often, it is essential to develop necessary features in Sockets. SocketOptions allows the user to set various standard options.
112+
113+
**5. SocketImplFactory**
114+
- The SocketImplFactory interface defines a factory for SocketImpl instances. It is used by the socket class to create socket implementations that implement various policies.
115+
116+
**6. ProtocolFamily**
117+
- This interface represents a family of communication protocols. The ProtocolFamily interface contains a method known as name(), which returns the name of the protocol family.
118+
119+
120+
121+
54122

55123
## Java Socket Programming
56124

@@ -69,6 +137,9 @@ A socket is simply an endpoint for communications between the machines. The Sock
69137
![socket-programming](https://user-images.githubusercontent.com/2780145/68625991-64f2e400-0500-11ea-9616-3702cb213cdd.png)
70138

71139
**Important methods :**
140+
|g|g|
141+
|-|-|
142+
|h|h|
72143
<table class="alt">
73144
<tbody><tr><th>Method</th><th>Description</th></tr>
74145
<tr><td>1) public InputStream getInputStream()</td><td>returns the InputStream attached with this socket.</td></tr>

0 commit comments

Comments
 (0)