Java的NIO通讯类库 KryoNet

jopen 13年前
     <p><img title="Java的NIO通讯类库 KryoNet" border="0" alt="Java的NIO通讯类库 KryoNet" src="https://simg.open-open.com/show/cbd16ea7e74893f855647c3087285338.png" width="57" height="55" /><br /> KryoNet这个Java类包提供了一套简洁的API来实现高效的,基于TCP和UDP协议的客户端/服务器NIO网络通信。KryoNet可以运行于桌面应用程序和Android平台中。由于KryoNet非常高效,所以特别适用于开发游戏应用程序和进程间通信。</p>    <p>示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">Server server = new Server(); server.start(); server.bind(54555, 54777); server.addListener(new Listener() {    public void received (Connection connection, Object object) {       if (object instanceof SomeRequest) {          SomeRequest request = (SomeRequest)object;          System.out.println(request.text);           SomeResponse response = new SomeResponse();          response.text = "Thanks!";          connection.sendTCP(response);       }    } });</pre>    <p></p>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326295387983" target="_blank">http://www.open-open.com/lib/view/home/1326295387983</a></p>