Libasio

A modern C++ network library based on asio for high performance network services
Alternatives To Libasio
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Cppserver988
2 months ago44mitC++
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Swarm31
7 years ago6otherC++
Swarm is aiming at your web
Crud28
5 years ago6C++
Restful web-service library written in C++11 based on Boost.ASIO and CRUD handlers
Queryperfpp15
8 years ago3iscC++
Asio_http15
8 years ago1C++
High performance HTTP library for Boost.Asio based on Joyent's http-parser and good intentions.
Libasio4
3 years agomitC++
A modern C++ network library based on asio for high performance network services
Vubercool3
5 years agogpl-3.0C++
Very high performance web application daemon
Cheapcrawler1
3 years agomitC++
Cheap modular c++ crawler library
Web_server1
2 years agounlicenseC++
This is a simple header only web server written in C++
Alternatives To Libasio
Select To Compare


Alternative Project Comparisons
Readme

libasio

A modern C++ network library based on asio for high performance network services

sample tcp server

#include <iostream>
#include "EventLoop.h"
#include "TcpServer.h"
#include "TcpConn.h"

void OnConnection(const TCPConnPtr& conn) {
	if (conn->IsConnected()) {
		std::cout << conn->GetName() <<" connection accepted.\n";
	}
	else if (conn->IsDisconnecting()) {
		std::cout << conn->GetName() <<" connection disconnecting.\n";
	}
}

void OnMessage(const TCPConnPtr& conn, ByteBuffer& buffer) {
    std::cout << "recv msg " << std::string(buffer.Data(), buffer.Size()) << std::endl;
    buffer.ReadBytes(buffer.Size());
    buffer.Normalize();
    conn->Send("server say hello!");
}

int main()
{
	EventLoop loop;
	TCPServer s(&loop, "0.0.0.0", 7788, "EchoServer", 4);
	s.SetConnectionCallback(OnConnection);
	s.SetMessageCallback(OnMessage);
	s.Init();
	s.Start();

	loop.Run();

	return 0;
}

sample tcp client

#include <iostream>
#include "EventLoop.h"
#include "TcpClient.h"
#include "TcpConn.h"

void OnConnection(const TCPConnPtr& conn) {
	if (conn->IsConnected()) {
		std::cout << conn->GetName() <<" connection accepted.\n";
                conn->Send("client say hello!");
	}
	else if (conn->IsDisconnecting()) {
		std::cout << conn->GetName() <<" connection disconnecting.\n";
	}
}

void OnMessage(const TCPConnPtr& conn, ByteBuffer& buffer) {
    std::cout << "recv msg " << std::string(buffer.Data(), buffer.Size()) << std::endl;
    buffer.ReadBytes(buffer.Size());
    buffer.Normalize();
    conn->Send("client say hello!");
}

int main()
{
	EventLoop loop;
	TCPClient client(&loop, "127.0.0.1", 7788, "EchoClient");
	client.Connect();
	client.SetAutoReconnect(true);
	client.SetConnCallback(OnConnection);
	client.SetMessageCallback(OnMessage);

	loop.Run();

	return 0;
}
Popular Performance Projects
Popular Asio Projects
Popular Software Performance Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Plus Plus
Network
Performance
Tcp
Asio
Tcp Client