06 2013 档案
只有注册用户登录后才能阅读该文。
摘要:异步服务器端: 1 #include <iostream> 2 #include <boost/asio.hpp> 3 #include <boost/bind.hpp> 4 #include <boost/shared_ptr.hpp> 5 #include <boost/date_time/posix_time/posix_time.hpp> 6 7 //using namespace std; 8 using namespace boost::asio; 9 10 class server11 {12 private:13 io
阅读全文
摘要:http://www.rosoo.net/a/201211/16386.html大家好,我是异步方式和同步方式不同,我从来不花时间去等那些龟速的IO操作,我只是向系统说一声要做什么,然后就可以做其它事去了。如果系统完成了操作, 系统就会通过我之前给它的回调对象来通知我。在ASIO库中,异步方式的函数或方法名称前面都有“async_” 前缀,函数参数里会要求放一个回调函数(或仿函数)。异步操作执行 后不管有没有完成都会立即返回,这时可以做一些其它事,直到回调函数(或仿函数)被调用,说明异步操作已经完成。在ASIO中很多回调函数都只接受一个boost::system::error_code参数,在
阅读全文
摘要:1 #include <iostream> 2 #include <boost/asio.hpp> 4 using namespace std; 5 using boost::asio::ip::tcp; 7 8 int main () 9 {10 try11 {12 //13 boost::asio::io_service ioservice;14 tcp::acceptor accept(ioservice,tcp::endpoint(tcp::v4(),6688));15 while(true)16 ...
阅读全文
摘要:http://blog.csdn.net/masikkk/article/details/5722258一 服务器端#include <winsock2.h>#include <ws2tcpip.h>#include <iostream.h>#include "tpipv6.h" // 所需库连接#pragma comment (lib,"Ws2_32.lib") void main(){ WSADATA wsaData; //版本协商 if (WSAStartup(MAKEWORD(2, 2), &wsaDa
阅读全文
摘要:source: http://www.cnblogs.com/wang7/archive/2012/05/24/2516808.html 首先我简单介绍一下同步TCP编程 与异步TCP编程。 1 (1)同步:在服务端我们通常用一个TcpListener来监听一个IP和端口。客户端来一个请求的连接,在服务端可以用同步的方式来接收,也可以用异步的方式去接收。比如:TcpListene server = new TcpListener(IPAddress.Parse("127.0.0.1"), port);TcpClient tc =server.AcceptTcpClient(
阅读全文
浙公网安备 33010602011771号