java java中的echo-server和client-server聊天应用程序有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10408798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 00:56:05  来源:igfitidea点击:

What is the difference between echo-server and client-server chat application in java?

javaclient-server

提问by Andy

Also I want to know what is main difference between Single Threaded and MultiThreaded Client-Server? I want to create a client server chat application.

另外我想知道单线程和多线程客户端服务器之间的主要区别是什么?我想创建一个客户端服务器聊天应用程序。

Server Form consist: 1 Textarea(text area) (to display text) 1 sendarea(text area) (to type the text to send) 1 Send button (to send the text which is typed in sendarea) it sends to client 1 exit button (closes application)

服务器窗体包括: 1 Textarea(文本区域)(显示文本) 1 sendarea(文本区域)(输入要发送的文本) 1 个发送按钮(发送在 sendarea 中输入的文本)它发送到客户端 1 个退出按钮(关闭申请)

Client Form consist: 1 Textarea(text area) (to display text) 1 sendarea(text area) (to type the text to send) 1 Send button (to send the text which is typed in sendarea) it sends to server 1 exit button (closes application)

客户端表单包括: 1 个 Textarea(文本区域)(显示文本) 1 个 sendarea(文本区域)(输入要发送的文本) 1 个发送按钮(发送在 sendarea 中输入的文本) 它发送到服务器 1 个退出按钮(关闭申请)

采纳答案by Darren

Single threads means 1 thread. Multi threading means multiple threads. What this means in term of your chat server is:

单线程意味着 1 个线程。多线程意味着多线程。就您的聊天服务器而言,这意味着:

If you have a single threaded server only 1 connection can be made to the server. Multithreading will allow you to create a new thread each time a new chat client connects and issue its own Input/output stream to send and receive chat messages.

如果您有一个单线程服务器,则只能与该服务器建立 1 个连接。多线程将允许您在每次新的聊天客户端连接时创建一个新线程并发出自己的输入/输出流来发送和接收聊天消息。

An echo server will just echo messages back from the 1 client connected where as a chat server will allow you to broadcast messages to other users and allow them to send messages to your client.

回显服务器只会从连接的 1 个客户端回显消息,而聊天服务器将允许您向其他用户广播消息并允许他们向您的客户端发送消息。

回答by npinti

This sounds a lot like home work so if it is you should mark it so.

这听起来很像家庭作业,所以如果是,你应该这样标记。

An echo server is usually an application which is used to test if the connection between a client and a server is successful. It consists of a server which sends back whatever text the client sent.

回显服务器通常是一个应用程序,用于测试客户端和服务器之间的连接是否成功。它由一个服务器组成,该服务器发送回客户端发送的任何文本。

A client-server is any environment in which you have a main node(server) to which other nodes (clients) connect to, usually to request some information.

客户端 - 服务器是任何环境,其中您有一个主节点(服务器),其他节点(客户端)连接到该主节点(服务器),通常是为了请求一些信息。

Single Threaded servers are servers which use 1 main thread to handle all requests. Usually these are used to handle very short requests such as synchronizing computer clocks. These are known as Iterative Servers.

单线程服务器是使用 1 个主线程来处理所有请求的服务器。通常这些用于处理非常短的请求,例如同步计算机时钟。这些被称为迭代服务器。

Multi Threaded servers are servers which use one ore more threads per client. This is usually the case with most application servers and is good for scalability. It also allows the servers to handle multiple clients at any one point in time. These are known as Concurrent Servers.

多线程服务器是每个客户端使用一个或多个线程的服务器。大多数应用程序服务器通常都是这种情况,并且有利于可扩展性。它还允许服务器在任何一个时间点处理多个客户端。这些被称为并发服务器。

I would recommend you take a look at thisOracle Tutorial. It should get you started and point you in the right direction.

我建议你看看这个Oracle 教程。它应该让你开始并指向正确的方向。