Java Networking

Networking in Java

Networking is provide communication between computer systems or devices and provide ability to exchange data between them. The package provides an object-oriented framework for the creation and use of Internet Protocol (IP) sockets

Networking Tutorials and Interview Questions

The Java Networking API ( package) provides the interfaces/classes for the following functions:


It is represent the IP address, which is either a 32- or 128-bit unsigned number used by IP. Package provides the following addressing-related classes

  • InetAddress
  • Inet4Address
  • Inet6Address
  • SocketAddress
  • InetSocketAddress
Making Transfer TCP connections

TCP (Transmission Control Protocol) is a connection-based protocol that provides a reliable flow of data between two computers

These classes are related to making normal TCP connections

  • ServerSocket
  • Socket
Making Transfer TCP connections

UDP (User Datagram Protocol) is a protocol that sends independent packets of data, called datagrams, from one computer to another with no guarantees about arrival.

UDP is not connection-based like TCP so many firewalls and routers have been configured not to allow UDP packets.The following are related to sending and receiving datagram packets via UDP.

  • DatagramPacket
  • DatagramSocket
Locating/Identifying Network Resources

These classes are related to locating or identifying network resources.

  • URI
  • URLClassLoader
  • URLConnection
  • URLStreamHandler
  • HttpURLConnection
  • JarURLConnection
Security-Security includes authentication- and permissions-related classes


Authentication of a user may be required in a number of situations, such as when a user tries to access a URL

  • Authenticator: The abstract class Authenticator has methods for authenticating a network connection.
  • PasswordAuthentication: PasswordAuthentication is simply a data holder for a user name and a password


Permissions relate to what actions may be performed.

  • SocketPermission: A SocketPermission consists of a host, with optional port range, and a set of actions that may be performed on that host ¬Ěconnect, accept, listen and/or resolve
  • NetPermission: NetPermission is a class for various named network permission