GithubHelp home page GithubHelp logo

libinzhangyuan / asio_kcp Goto Github PK

View Code? Open in Web Editor NEW
661.0 661.0 190.0 4.41 MB

combine kcp with boost::asio. - kcp: a Fast and Reliable udp protocal.

License: GNU General Public License v2.0

Shell 1.68% Makefile 21.38% C++ 57.84% C 16.99% CMake 0.94% Vim Script 1.17%

asio_kcp's People

Contributors

libinzhangyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asio_kcp's Issues

UDP上用recv返回0的问题

windows下client_lib在使用的时候,会连接后立马callback断开
原因是recv传入了一个udp socket,然后recv返回0就认为断开。
但是udp是无连接的,recv返回0有可能是认为空数据包,是正常结果

how to filter log? why so much log?

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|169
170|[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|171
172|[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|173
174|[email protected]_wait
@asio|1508310907.273161|<273161|
@asio|1508310907.278537|>174|ec=system:0

请求消息内容过大时会被截断为固定352256大小

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);

quick_make failed

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

Memory leak

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

发送大文件的时候,发送速度呈现波浪形

KCP传输
发送大文件,测试的是100M的文件,其实发送文件都会有这样的问题。
速度变动非常大,呈现出波状的。是哪里调用有问题。
发送和接收的窗宽已经都调整成3000了。
使用环境是windows7 64位的操作系统
RTT=200左右

client_lib 编译出错

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里已经包含,有谁遇见过吗?

Misuse ostringstream.str() ?

`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;
}

}`

How to run benchmark prog?

@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!

kcp_client_wrap

调用connect直接死循环卡死了
connect_async没有实现

启动即崩溃:/lib64/libpthread.so.0

[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)

谢谢作者。

asio线程安全疑问

kcp库是非线程安全的(ikcp_send/recv ikcp_input/output ikcp_update 应该在同一线程中调用)
看了一下代码 ikcp_update在timer周期回调里 接收数据在接收回调里
我想咨询一下 asio内部是单线程的吗? asio可以确保线程安全吗?

connect() and close()

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.

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.