java 如何使用java nio编写完整的服务器客户端通信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/788786/
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-29 13:47:00  来源:igfitidea点击:

how to write a complete server client communication using java nio

javasocketsnio

提问by Deepak

I am new to java NIO. I have to write a simple server client communication program using Java NIO.

我是 Java NIO 的新手。我必须使用 Java NIO 编写一个简单的服务器客户端通信程序。

Is there any sample programs or any link where can I go for this?

是否有任何示例程序或任何链接我可以去哪里?

采纳答案by jassuncao

You might give a look at Apache Mina. If you only want to learn java NIO it might me a little to hard to grasp.

你可以看看Apache Mina。如果你只想学习 Java NIO,我可能有点难以掌握。

回答by Aries McRae

Apache Mina
http://mina.apache.org
Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily.

Apache Mina
http://mina.apache.org
Apache MINA 是一个网络应用框架,可以帮助用户轻松开发高性能和高扩展性的网络应用。

xSocket
http://xsocket.org/
xSocket is an easy to use NIO-based library to build high performance, highly scalable network applications.

xSocket
http://xsocket.org/
xSocket 是一个易于使用的基于 NIO 的库,用于构建高性能、高度可扩展的网络应用程序。

JBoss Netty
http://netty.io/
The Netty project is an effort to provide an asynchronous event-driven network application framework and tools for rapid development of maintainable high performance and high scalability protocol servers and clients.

JBoss Netty
http://netty.io/
Netty 项目致力于提供异步事件驱动的网络应用程序框架和工具,用于快速开发可维护的高性能和高可扩展性协议服务器和客户端。

Sun MicroSystem's Grizzly
https://grizzly.java.net/
The Grizzly framework has been designed to help developers to take advantage of the Java NIO API. Grizzly goals is to help developers to build scalable and robust servers using NIO.

Sun MicroSystem 的 Grizzly
https://grizzly.java.net/
Grizzly 框架旨在帮助开发人员利用 Java NIO API。Grizzly 的目标是帮助开发人员使用 NIO 构建可扩展且健壮的服务器。

NIO Framework
http://nioframework.sourceforge.net
The NIO Framework is a library on top of NIO that hides most of the complexity of plain NIO. With the NIO Framework you can implement high-performance Java network applications without having to deal with all the nasty details of NIO.

NIO Framework
http://nioframework.sourceforge.net
NIO Framework 是 NIO 之上的一个库,它隐藏了普通 NIO 的大部分复杂性。使用 NIO 框架,您可以实现高性能的 Java 网络应用程序,而无需处理 NIO 的所有讨厌的细节。

QuickServer
http://www.quickserver.org
QuickServer is an open source Java library/framework for quick creation of robust multi-client TCP server applications. QuickServer provides an abstraction over the ServerSocket, Socket and other network and input output classes and it eases the creation of powerful network servers.

QuickServer
http://www.quickserver.org
QuickServer 是一个开源 Java 库/框架,用于快速创建强大的多客户端 TCP 服务器应用程序。QuickServer 提供了对 ServerSocket、Socket 和其他网络和输入输出类的抽象,它简化了强大网络服务器的创建。

回答by Peter Lawrey

Have a look in your JDK under the directory called sample

在名为sample的目录下查看您的 JDK

回答by Brian Agnew

You should look at the online tutorials available. Building Highly Scalable Servers with Java NIOlooks particularly relevant.

您应该查看可用的在线教程。使用 Java NIO 构建高度可扩展的服务器看起来特别重要。

IBM has a tutorial(registration required) whilst Sun has some simple examplesof the different facilities of NIO (not just client/server APIs)

IBM 有一个教程(需要注册),而 Sun 有一些NIO 不同设施的简单示例(不仅仅是客户端/服务器 API)

回答by Artyom Sokolov

I beleive you should take a look on Apache HttpComponentsif your applcation uses HTTP, of course. There are several examples provided within downloadable library archive. Note that httpcore, httpcore-nio and httpclient are part of the project.

我相信如果您的应用程序使用 HTTP,您应该看看Apache HttpComponents,当然。可下载的图书馆档案中提供了几个示例。请注意,httpcore、httpcore-nio 和 httpclient 是项目的一部分。

Cheers.

干杯。