All Projects → alberliu → gn

alberliu / gn

Licence: MIT License
golang epoll实现

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Labels

Projects that are alternatives of or similar to gn

llb
Dead simple event-driven load-balancer
Stars: ✭ 27 (-41.3%)
Mutual labels:  epoll
epoller
epoll implementation for connections in Linux, MacOS and Windows
Stars: ✭ 58 (+26.09%)
Mutual labels:  epoll
30dayMakeCppServer
30天自制C++服务器,包含教程和源代码
Stars: ✭ 432 (+839.13%)
Mutual labels:  epoll
ZLToolKit
一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
Stars: ✭ 1,302 (+2730.43%)
Mutual labels:  epoll
liblw
An asynchronous application framework built on C++ coroutines and epoll.
Stars: ✭ 34 (-26.09%)
Mutual labels:  epoll
tunnel
一款单线程、轻量级和高性能的内网穿透程序,支持TCP流量转发(支持所有TCP上层协议,包括HTTP,SSH等),支持多客户端同时连接
Stars: ✭ 39 (-15.22%)
Mutual labels:  epoll
async
⏱ Promises and reactive-streams in Swift built for high-performance and scalability.
Stars: ✭ 35 (-23.91%)
Mutual labels:  epoll
toyhttpd
I/O 模型练手代码,分别使用阻塞式 I/O、select、poll 和 epoll 和 Java NIO 实现了简单的 HTTP Server
Stars: ✭ 43 (-6.52%)
Mutual labels:  epoll
Mgx
🌈 A high performance network framework written in c++ (support tcp and http)
Stars: ✭ 15 (-67.39%)
Mutual labels:  epoll
Tiginx
Tiginx is a Shanzhai Nginx project , please buyao use it xian , if meet problem , I no fuze ...
Stars: ✭ 29 (-36.96%)
Mutual labels:  epoll
netman
高性能的TCP网络框架、支持TLS、可配置的路由、websocket、基于事件循环(epoll),百万连接(C1000K)
Stars: ✭ 96 (+108.7%)
Mutual labels:  epoll
lce
linux网络编程框架(C++)基于Reactor事件机制,支持线程池,异步非阻塞,高并发,高性能
Stars: ✭ 61 (+32.61%)
Mutual labels:  epoll
epump
ePump是一个基于I/O事件通知、非阻塞通信、多路复用、多线程等机制开发的事件驱动模型的 C 语言应用开发框架,利用该框架可以很容易地开发出高性能、大并发连接的服务器程序。
Stars: ✭ 26 (-43.48%)
Mutual labels:  epoll
WebServer
C++高性能网络服务器
Stars: ✭ 53 (+15.22%)
Mutual labels:  epoll
epoll
epoll(7) binding in Ruby
Stars: ✭ 22 (-52.17%)
Mutual labels:  epoll
connect
tiny cross-platform socket API library
Stars: ✭ 46 (+0%)
Mutual labels:  epoll
libapenetwork
Fast cross-platform async network library
Stars: ✭ 17 (-63.04%)
Mutual labels:  epoll
xm2cloud term
powerful webssh that developed with django, channels, xterm,ioloop
Stars: ✭ 17 (-63.04%)
Mutual labels:  epoll
libevent
<Libevent深入浅出>本书要求有一定的服务并发编程基础,了解select和epoll等多路I/O复用机制。
Stars: ✭ 363 (+689.13%)
Mutual labels:  epoll
sol
Lightweight MQTT broker, written from scratch. IO is handled by a super simple event loop based upon the most common IO multiplexing implementations.
Stars: ✭ 72 (+56.52%)
Mutual labels:  epoll

gn

简述

gn是一个基于linux下epoll的网络框架,目前只能运行在Linux下环境,gn可以配置处理网络事件的goroutine数量,相比golang原生库,在海量链接下,可以减少goroutine的开销,从而减少系统资源占用。

支持功能

1.tcp拆包粘包
通过调用系统recv_from函数,使用系统读缓存区实现拆包,减少用户态内存分配,使用sync.pool申请读写使用的字节数组,减少内存申请开销以及GC压力。
2.客户端超时踢出
可以设置超时时间,gn会定时检测超出超时的TCP连接(在指定时间内没有发送数据的连接),进行释放。

使用方式

package main

import (
	"github.com/alberliu/gn"

	"time"
)

var log = gn.GetLogger()

var server *gn.Server

var encoder = gn.NewHeaderLenEncoder(2, 1024)

type Handler struct {
}

func (Handler) OnConnect(c *gn.Conn) {
	log.Info("connect:", c.GetFd(), c.GetAddr())
}
func (Handler) OnMessage(c *gn.Conn, bytes []byte) {
	encoder.EncodeToFD(c.GetFd(), bytes)
	log.Info("read:", string(bytes))
}
func (Handler) OnClose(c *gn.Conn, err error) {
	log.Info("close:", c.GetFd(), err)
}

func main() {
	var err error
	server, err = gn.NewServer(":8080", Handler{}, gn.NewHeaderLenDecoder(2),
		gn.WithTimeout(1*time.Second, 5*time.Second), gn.WithReadBufferLen(10))
	if err != nil {
		log.Info("err")
		return
	}

	server.Run()
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].