libinzhangyuan / asio_kcp Goto Github PK
View Code? Open in Web Editor NEWcombine kcp with boost::asio. - kcp: a Fast and Reliable udp protocal.
License: GNU General Public License v2.0
combine kcp with boost::asio. - kcp: a Fast and Reliable udp protocal.
License: GNU General Public License v2.0
I do not like go lang!
Thank you!
这不是阻塞了么? asio的意义在哪里
windows下client_lib在使用的时候,会连接后立马callback断开
原因是recv传入了一个udp socket,然后recv返回0就认为断开。
但是udp是无连接的,recv返回0有可能是认为空数据包,是正常结果
like this log,how this log is closed? thanks!
@asio|1508310907.245388|168|[email protected]
@asio|1508310907.245393|168169|[email protected]_wait
@asio|1508310907.245400|<245400|
@asio|1508310907.250925|>169|ec=system:0
@asio|1508310907.250940|169|[email protected]
@asio|1508310907.250944|169170|[email protected]_wait
@asio|1508310907.250949|<250949|
@asio|1508310907.256449|>170|ec=system:0
@asio|1508310907.256466|170|[email protected]
@asio|1508310907.256471|170171|[email protected]_wait
@asio|1508310907.256476|<256476|
@asio|1508310907.261937|>171|ec=system:0
@asio|1508310907.261954|171|[email protected]
@asio|1508310907.261958|171172|[email protected]_wait
@asio|1508310907.261963|<261963|
@asio|1508310907.267578|>172|ec=system:0
@asio|1508310907.267609|172|[email protected]
@asio|1508310907.267615|172173|[email protected]_wait
@asio|1508310907.267621|<267621|
@asio|1508310907.273136|>173|ec=system:0
@asio|1508310907.273152|173|[email protected]
@asio|1508310907.273156|173174|[email protected]_wait
@asio|1508310907.273161|<273161|
@asio|1508310907.278537|>174|ec=system:0
I don't know much about asio, how to build a dependency library for Android and iOS based on this project
People will be helped so much if you just take (maybe 30 mins or so) to write step-by-step documentation to build a server & client in English. You have worked this far, now you can also do it to make the project great in the game devs. world.
Thanks.
server的event_callback取到的消息大小为固定的352256
void GWServer::event_callback(kcp_conv_t conv, kcp_svr::eEventType event_type, std::shared_ptrstd::string msg)
{
AK_WARNING_LOG << "cannot parse request: " << msg->size() << std::endl;
}
client:
asio_kcp::kcp_client_wrap net;
flatbuffers::FlatBufferBuilder builderOut;
builderOut.PushBytes(reinterpret_cast<unsigned char*>(const_cast<char*>(msg.data())), msg.size());// msg size: 10M
net.send_msg(msg);
linux@linux-desktop:~/github/libinzhangyuan/asio_kcp$ sh quick_make.sh
[-------------------------------]
essential
[-------------------------------]
g++ -std=c++11 -Wall -D _UTEST_ -g3 -c _src/check_function.cpp -o _src/check_function.o
g++ -std=c++11 -Wall -D _UTEST_ -g3 -c _src/utility/strutil.cpp -o _src/utility/strutil.o
ar -cr essential.a ./_src/check_function.o ./_src/utility/strutil.o
[-------------------------------]
server_lib
[-------------------------------]
make: Nothing to be done for 'all'.
[-------------------------------]
server
[-------------------------------]
g++ -std=c++11 -Wall -I /usr/include -I ../third_party/muduo -I ../server_lib -I ../third_party/g2log/src -g3 -D BOOST_ASIO_ENABLE_HANDLER_TRACKING -D BOOST_ASIO_ENABLE_BUFFER_DEBUGGING -D MUDUO_STD_STRING -D __GXX_EXPERIMENTAL_CXX0X__ -D AK_ENABLE_UDP_PACKET_LOG -c main.cpp -o main.o
main.cpp:18:8: error: ‘scoped_ptr’ in namespace ‘boost’ does not name a template type
boost::scoped_ptr<muduo::LogFile> g_logFile;
^~~~~~~~~~
main.cpp:18:1: note: suggested alternative: ‘shared_ptr’
boost::scoped_ptr<muduo::LogFile> g_logFile;
^~~~~
shared_ptr
main.cpp: In function ‘void dummyOutput(const char*, int)’:
main.cpp:24:9: error: ‘g_logFile’ was not declared in this scope
if (g_logFile)
^~~~~~~~~
main.cpp: In function ‘int main(int, char**)’:
main.cpp:59:9: error: ‘g_logFile’ was not declared in this scope
g_logFile.reset(new ::muduo::LogFile(basename, rollSize, threadSafe, flushInterval, checkEveryN));
^~~~~~~~~
make: *** [Makefile:184: main.o] Error 1
Hi, i have ran the asio_kcp in centos. But i found there is memory leak from server_lib. Do you know what may cause this... thanks!
[root@ ~]# free
total used free shared buffers cached
Mem: 1922244 237748 1684496 0 12260 155564
-/+ buffers/cache: 69924 1852320
Swap: 0 0 0
[root@ ~]# free
total used free shared buffers cached
Mem: 1922244 238104 1684140 0 12268 155972
-/+ buffers/cache: 69864 1852380
Swap: 0 0 0
[root@ ~]# free
total used free shared buffers cached
Mem: 1922244 250132 1672112 0 12532 167364
-/+ buffers/cache: 70236 1852008
Swap: 0 0 0
g++ -Wall -g3 -c kcp_client.cpp -o kcp_client.o
kcp_client.cpp: In member function ‘void asio_kcp::kcp_client::do_send_connect_packet(uint64_t)’:
kcp_client.cpp:149:108: error: ‘strerror’ was not declared in this scope
std::cerr << "do_asio_kcp_connect send error return with errno: " << errno << " " << strerror(errno) << std::endl;
头文件<string.h> 在.cpp里已经包含,有谁遇见过吗?
`void kcp_client::do_recv_udp_packet_in_loop(void)
{
if (ret_recv < 0)
{
std::ostringstream ostrm;
std::string err_detail = ostrm.str();
ostrm << "do_asio_kcp_connect recv error return with errno: " << err << " " << strerror(err);
std::cerr << err_detail << std::endl;
return;
}
}`
@libinzhangyuan
Happy to see your code.
I need to persistent real send data from USA to China.
So I want to run bench mark first to see the speed.
I checkout tag kcp_bench_mark_test but didn't see asio_kcp_server and asio_kcp_client.
Is there anything I did wrong?
Need your help!
Thank you very much!
老板,请教个问题啊,muduo模块主要用来做什么的呢?既然都用了asio?看代码是日志系统吗?
调用connect直接死循环卡死了
connect_async没有实现
[game@VM_109_84_centos server]$ ./server 0.0.0.0 12345
FILE ERROR: could not open log file:[/var/log/asio_kcp_log/server.g2log.20180209-114600.log]
std::ios_base state = 4
Cannot write logfile to location, attempting current directory
***** FATAL TRIGGER RECEIVED *******
Received fatal signal: SIGSEGV(11)
PID: 15238
stack dump [1] /lib64/libpthread.so.0+0xf370 [0x7f36bbd7e370]
stack dump [2] /lib64/libc.so.6setbuffer+0x7 [0x7f36bba1b597]
stack dump [3] ./server() [0x43e0c0]
stack dump [4] ./server() [0x43e1f6]
stack dump [5] ./server() [0x41901e]
stack dump [6] /lib64/libc.so.6__libc_start_main+0xf5 [0x7f36bb9cfb35]
stack dump [7] ./server() [0x4074b4]
***** RETHROWING SIGNAL SIGSEGV(11)
g2log exiting after receiving fatal event
Log file at: [./server.g2log.20180209-114600.log]
Exiting - FATAL SIGNAL: 11 段错误
系统版本
[game@VM_109_84_centos server]$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
GCC/G++版本
[game@VM_109_84_centos server]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
谢谢作者。
kcp库是非线程安全的(ikcp_send/recv ikcp_input/output ikcp_update 应该在同一线程中调用)
看了一下代码 ikcp_update在timer周期回调里 接收数据在接收回调里
我想咨询一下 asio内部是单线程的吗? asio可以确保线程安全吗?
I think you should implement connect() and close(), just like syn and fin.
The connect() send the SYN and wait SYN/ACK to make sure the server exist.
And the close() send the FIN and wait FIN/ACK.
If the server receive a packet which does not match the conv, a RST packet should send out.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.