Simple Java example of TCP Client/Server communication

Опубликовано: 26 Март 2026
на канале: j.Buddy Erik
8,839
3

It's a simple example to implement TCP Client/Server in Java. To test the function, start JavaTCPServer with port number in Terminal. The server will open a ServerSocket and wait for incoming message from client. Then start JavaTCPClient with IP address and port number in another Terminal, then enter anything. The user input will be sent to JavaTCPServer via TCP socket, when JavaTCPServer receive the message, it will echo back to JavaTCPClient, then both JavaTCPServer and JavaTCPClient close the socket.

source code:
http://java-buddy.blogspot.com/2014/0...