//
// chat_client.cpp
// ~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
//boost开发文档中实时聊天程序的客户端
//实现的大致思路是:在创建的客户端实例中初始化socket、连接服务器端,并且不断的进行着异步读操作(从服务器端读数据)
//在主线程中,从console中不断读取要被发送的消息,并且把这些消息post至io_service,然后进行异步写操作
//读写socket都是用异步操作
//这种方法不同于分别开一个读线程,一个写线程, 它的优势是线程不会一直等待读写数据,在并发数大的情况下通过异步读写能提高资源利用率
#include
#include
#include
#include
#include
#include
#include "chat_message.hpp"
using boost::asio::ip::tcp;
typedef std::deque chat_message_queue;
class chat_client
<