post score 0 times, average 0.0

Problem Overview

Implement the EchoServer and EchoClient classes, where EchoServer listens on a port number (passed through parameters when it starts) and waits for client access; EchoClient connects to the server based on the incoming server address (IP address or domain name) and port number at startup; After connecting, read the user's input on the command line and transfer the input to EchoServer. After EchoServer is received, return EchoServer received: + user input information; EchoClient receives the return message and outputs it to the command line, and continues. Waiting for user input

1, the client EchoClient.java code

 

2. Single-threaded server-side EchoServer.java code

3, multi-threaded server-side code

ThreadEchoServer.java:

Handler.java

 

  
 

This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/ssd8-ex1-socket-communication-java-code-2.html

Post comment

Style

No Comment

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW