Tag: java client socket example tutorial

Communication with TCP/IP Protocol Java

March 24, 2011 · 2 min read
Java is very strong in communication world. To support, LAN programming, the **java.net** package comes with two classes **Socket** and **ServerSocket**. The meaning and purpose these classes and network related basics, you have studied in [Networking – Introduction](http://way2java.com/networking/networking-introduction/). Socket and ServerSocket are extensively I/O streams for data traversal and for this reason, sockets are called as **stream sockets**. These two classes are very confusing for a novice. Let us make it clear. Socket job is to request the connection with the server and ServerSocket job is to bind the connection on the port number requested by the client. When a port number is binded by the server, it is allotted to the client as long as client wants. When client gets disconnected, the port number on the server gets freed and server can allot the port number to some other client, may be waiting.