Socket programming in java: java.net package contains all the classes and interfaces to avail networking in java. TCP and UDP are two main protocols of Communication and belong to TCP/IP suite. We can establish bidirectional communication link with the help of java.net package. java.net package can be roughly divided into two parts low level APIs with implementations of Addresses, Sockets and Network interfaces and high level APIs of URI, URL and different connections implementations. A socket is bound to a port number which is 2-byte unsigned integer that is kept in the header appended with the message. The range for the port number is from 0 to 65535. URL, HttpURLConnection , Socket, InetAddress are important classes of java.net package.