Send Messages from Client to Server in Java
Learn how to build a Client-Server system and send messages from the client with Java using the java.net package.
The java.net package in Java contains classes and interfaces to build distributed Java Applications on the basis of Socket Programming.
A Socket is one endpoint of a two-way communication link between two programs on a network.It is a combination of an IP Address and a binding Port number. In the example below, we use the localhost (127.0.0.1) as the preferred IP Address and a Port number 2222.
Client Program |
Server Program |
Implementations
Press Ctrl+C to terminate a Program.