NIO框架 yanf4j

码农软件 · 软件分类 · 网络工具包 · 2019-03-02 18:29:47

软件介绍

有这么多nio框架了,为什么要another?重复造轮 子也罢,这框架脱胎于一个服务器项目的网络层代码,期间参考了cindy、grizzly等nio框架的实现,加上自己的一些心得体会实现的。特点是简 单、小巧、超轻量级。项目没有多大野心,目标是高效、简单地实现非阻塞模式的Server和Client(包括UDP和TCP)并且保证不错的性能要求, 不提供阻塞模式。如果你的项目需要实现一个socket server/client并且不希望用太重量级的框架,yanf4j是个不错的选择。目前仅支持 jdk>=6.0 ,毕竟nio在>=6.0以上版本的jdk中有最好的表现。

示例代码:时间服务器

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.code.yanf4j.nio.Session;
import com.google.code.yanf4j.nio.impl.HandlerAdapter;

public class TimeHandler extends HandlerAdapter{

        @Override
        public void onSessionStarted(Session session) {
                Date date = new Date();
                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH🇲🇲ss");
                session.asyncWrite(dateFormat.format(date));
                session.flush();
                session.close();
               
        }
}

本文地址:https://codercto.com/soft/d/482.html

Handbook of Data Structures and Applications

Handbook of Data Structures and Applications

Dinesh P. Mehta / Chapman and Hall/CRC / 2004-10-28 / USD 135.95

In the late sixties, Donald Knuth, winner of the 1974Turing Award, published his landmark book The Art of Computer Programming: Fundamental Algorithms. This book brought to- gether a body of kno......一起来看看 《Handbook of Data Structures and Applications》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具