开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约

halx99 / mini-asioC

指数
0
Watch 5 Star 2 Fork 3
加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
A mini and extremely simple cross platform socket wrapper APIs, support win32 & linux & ios & android & wp8 & wp8.1-universal & win10-universal 展开 收起

Loading...
README.md

mini-asio

A lightweight & stable cross platform posix socket API wrapper, support win32 & linux & apple & android & wp8 & wp8.1-universal & win10-universal
Used by http://hongjing.qq.com/
support IPv6-only network.
support multi-connections at one thread.
support deadline timer.
processing tcp sticky internal, user do not need to care it.

Usage(since v3.9 c++17 required):

  1. Only compile src\xxsocket.cpp src\masio.cpp with your project; For gcc, you must add --std=c++17 compile flag
  2. demo code:
#include "xxsocket.h"
using namespace purelib::inet;
void test_connect() 
{
   xxsocket clientsock;
   // The interface xpconnect_n will detect whether localhost is IPV6 only network automatically
   // and connect the ipv4 server by V4MAPPED address.
   if(0 == clientsock.xpconnect_n("www.baidu.com", 443, std::chrono::seconds(5)/* connect timeout 5 seconds */))
   {
       printf("connect succeed\n");
   }
}

ASIO Usage(Client Program):

cpptest: https://github.com/halx99/mini-asio/blob/master/test/test/cpptest.cpp
luatest: open https://github.com/halx99/mini-asio/blob/master/test/test/luatest.xsxproj by x-studui365 ide

#pitfall: For Microsoft Visual Studio, if your project has specific precompiled header, you should include it at head of xxsocket.cpp or specific the compile option: C/C++ --> Advance -->'Forced Include File' to it(such as pch.h).

项目点评 ( 0 )

你可以在登录后,发表评论

搜索帮助