This is a mini cross platform posix socket API wrapper, support win32 &
linux & ios & android & wp8 & wp8.1-universal &
win10-universal
It also support IPv6-only network.
usage:
#include "xxsocket.h"
using namespace purelib::net;
// server
xxsocket tcpserv;
if(0 == tcpserv.pserv("192.168.1.23"/*could be ipv6 address*/, 2016)) {
xxsocket cli = tcpserv.accept();
char buffer[256];
cli.recv(buffer, sizeof("hello server"));
}
// client
xxsocket tcpcli;
if(0 == tcpserv.xpconnect("192.168.1.23"/*could be ipv6 address or hostname*/, 2016)) {
tcpcli.send(buffer, sizeof("hello server"));
}
Is this lib is not depending on any Third party libs like boost . for A sync and UDP
you absolutely got here something that is missing from the c++ world and cocos2d-x .
Well done
update v3.0-rel
1.Support multi-channels at 1 thread service.
2.Async reconnect support
3.Optimize log for cross platform
4.Optimize log for cocos2d, avoid crash
5.Optimize unpack logic
6.Avoid buffer attack
7.Integrate c-ares support, macro: _USE_ARES_LIB, default value is 0
8.Add macros to control whether use object pool, shared_ptr and enable send callback
9.Fix shutdown can’t close connection.
10.object_pool, thread safe support
[mini-asio][1532866023984774] [index: 0] connecting server 203.162.71.67:80…
[mini-asio][1532866023986874] [index: 0] the connection [0.0.0.0:52783] —> 203.162.71.67:80 is established.
[mini-asio][1532866023987859] [index: 1] connecting server www.ip138.com:80…
[mini-asio][1532866023988676] [index: 0] do_write error, the connection should be closed, retval=-1, ec:10057, detail:A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
[mini-asio][1532866023998673] [index: 1] the connection [192.168.33.107:52784] —> 42.114.104.27:80 is established.
[mini-asio][1532866083426316] [index: 1] do_read error, the server close the connection, retval=0, ec:0, detail:The operation completed successfully.
Update to v3.9.0
1. Add Lua bindings with sol2 support, see https://github.com/halx99/mini-asio/blob/master/test/test/example.lua
2. Remove game engine specific code
3. Upgrade c++ require standard to c++17
4. Deep integration binary stream encode/decode, and export to Lua
5. Update protocol autogen tool for new lua bindings
6. Remove set_callbacks, only need set event callback at start_service.
Update to v3.9.1 1. Make required std::string_view backport to C++11 standard 2. Fix compile errors & warnings for GCC
You wrote c++17. As far as I know Android can use it only since API level 21 (Lollipop), starting in NDK r18. The default cocos template will use older versions. So everbody with support for older devices can’t use your library.