Git Product home page Git Product logo

luves's Introduction

#Luves

Luves是一个轻量级的事件触发网络库,封装了Socket,简化基于Socket程序开发。目标是封装了以下三种事件的响应:IO事件,定时器事件,信号事件。支持跨平台,OS X环境使用kqueue模型,Linux环境使用Epoll模型。实现以下两种服务器框架模型:半同步/半异步(HSHA),领导者/跟随者(LF)。

## 写在前面

将自己理解的网络框架以"学习"的标准实现,简化复杂网络库的细节部分,实现网络库的本质,必要的地方注释了代码实现思路。受限于自身技术水平,目前项目存在很多BUG,欢迎提出PR或更好的建议。

## 安装

## 技术实现

## 示例 简单的半同步/半异步服务器

#include "luves.h"
using namespace luves;

void GetInput(const TcpConnPtr & conn)
{
	std::cout<<conn->GetInputBuffer();
}

int main()
{
	EventLoop loop;
	Ip4Addr server_addr("127.0.0.1",8080);
	HshaServer server(&loop, server_addr,4);
	server.SetReadCb(GetInput);
	server.SetWriteCb([](const TcpConnPtr & conn)
                  {conn->Send("HTTP/1.1 200 OK\r\n"
                              "Content-Type:text/html;charset=utf-8\r\n"
                              "Content-Length:18\r\n"
                              "\r\n"
                              "Welcome to tinyweb");});
	server.RunServer();
	loop.loop();
}

## 版本更新日志 Version 0.01

  • 原型开发,目前仅使用kqueue,暂支持OS X系统,实现半同步半异步服务器框架.封装了IO事件与定时事件。

## License MIT

luves's People

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.