http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/echo/async_udp_echo_server.cpp”rel=“noreferer”
{
ctr++;
cout<<"Counter: "<<ctr<<" data= "<<data<<endl;
socket_.async_receive_from(boost::asio::buffer(data_, max_length), sender_endpoint_,boost::bind(&server::handle_receive_from, this,boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
}
意图是每当处理民盟的连接时,基本上增加反面。
测试客户正在发送此类数据。
for(;;){
ctr++;
printf("ctr= %lu
",ctr);
snprintf(buf2, 10,"%lu",ctr);
if ((numbytes = sendto(sockfd, buf2, strlen(buf2), 0,p->ai_addr, p->ai_addrlen)) == -1)
{
perror("client: sendto");
exit(1);
}
}
在管理测试客户之后,我看到服务器方面:
Counter= 358239 data= 369880
the data part shows the message #. The test client has indeed sent 369880 messages but as you can see counter is only 358239 (drop of 11641 messages).
这里可能有什么错误?
Both hosts (sender and receiver, running Ubuntu 10.04 LTS) are okay with resources- I don t see CPU, memory or network saturating.
<代码>netstat-su的输出情况类似
Udp:
38569571 packets received
1003583 packets to unknown port received.
74619 packet receive errors
267 packets sent
RcvbufErrors: 74619
How do I troubleshoot large number of packets to unknown port received
?