Java Networking
Java Networking refers to the practice of linking multiple computing devices to facilitate the sharing of resources between them.
Java socket programming enables the exchange of data among various computing devices.
Advantage of Java Networking
- Sharing resources
- Centralize software management
- How to perform connection-oriented Socket Programming in networking ?
- How to display the data of any online web page ?
- How to get the IP address of any host name e.g. www.google.com ?
- How to perform connection-less socket programming in networking ?
Within the java.net package, there are two protocols available:
- Transmission Control Protocol (TCP): This protocol ensures dependable communication between the transmitter and receiver. TCP is commonly paired with the Internet Protocol, forming TCP/IP.
- User Datagram Protocol (UDP): UDP offers a connectionless protocol service, enabling the transmission of data packets between multiple nodes without establishing a formal connection.
Java Networking Terminology
The widely used Java networking terminologies are given below:
- IP Address
- Protocol
- Port Number
- MAC Address
- Connection-oriented and connection-less protocol
- Socket
1) IP Address
An IP address is a distinctive numerical label allocated to a device within a network, such as 192.168.0.1. It consists of octets that vary from 0 to 255.
It is a logical address that can be changed.
2) Protocol
A protocol is a set of rules basically that is followed for communication. For example:
- Telnet
- SMTP
- POP etc.
3) Port Number
Port numbers are essential for distinguishing between various applications, serving as endpoints for communication between them.
A port number is linked to an IP address to facilitate communication between two applications.
4) MAC Address
A MAC (Media Access Control) address serves as a distinct identifier for a NIC (Network Interface Controller). While a network node may possess several NICs, each one is assigned a unique MAC address.
As an illustration, an Ethernet adapter could be assigned a MAC address such as 00:0d:83::b1:c0:8e.
5) Connection-oriented and connection-less protocol
Acknowledgment is sent by the recipient in connection-oriented protocols, making them reliable albeit slower. TCP is a prime example of a connection-oriented protocol.
In a connection-less protocol, the receiver does not send acknowledgments, making it fast but less reliable. UDP is an instance of a connection-less protocol.
6) Socket
A socket serves as a connection point for bidirectional communication.
Visit next page for Java socket programming.
java.net package
Within the java.net package, there are two main categories:
- Low-Level API: This section focuses on handling networking identifiers, bidirectional data communication through Sockets, and network interfaces.
- High-Level API: This part is concerned with managing Universal Resource Identifiers (URIs), Universal Resource Locators (URLs), and establishing connections to resources indicated by URLs.
The java.net package provides many classes to deal with networking applications in Java. A list of these classes is given below:
- Authenticator
- CacheRequest
- CacheResponse
- ContentHandler
- CookieHandler
- CookieManager
- DatagramPacket
- DatagramSocket
- DatagramSocketImpl
- InterfaceAddress
- JarURLConnection
- MulticastSocket
- InetSocketAddress
- InetAddress
- Inet4Address
- Inet6Address
- HttpURLConnection
- HttpCookie
- NetPermission
- NetworkInterface
- PasswordAuthentication
- Proxy
- ProxySelector
- ResponseCache
- SecureCacheResponse
- ServerSocket
- Socket
- SocketAddress
- SocketImpl
- SocketPermission
- StandardSocketOptions
- URLClassLoader
- URLConnection
- URLDecoder
- URLEncoder
- URLStreamHandler
List of interfaces available in java.net package:
- ContentHandlerFactory
- CookiePolicy
- CookieStore
- DatagramSocketImplFactory
- FileNameMap
- SocketOption<T>
- SocketOptions
- SocketImplFactory
- URLStreamHandlerFactory
- ProtocolFamily
- Networking and Networking Terminology
- Socket Programming (Connection-oriented)
- URL class
- Displaying data of a webpage by URLConnection class
- InetAddress class
- DatagramSocket and DatagramPacket (Connection-less)