Example #1
0
    ~asio_connection()
    {
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT >= 0x0600)
        socket_.cancel();
#endif
        //socket_.shutdown(socket_base::shutdown_both);
        socket_.close();
    }
void cia_client::stop()
{
	if (!m_started_) return;
	m_started_ = false;
	m_sock_.close();
	m_deal_ch_msg_group.interrupt_all();

	ptr self = shared_from_this();
	auto it = std::find(clients.begin(), clients.end(), self);
	clients.erase(it);
	BOOST_LOG_SEV(cia_g_logger, Debug) << "客户端socket已经调用stop函数关闭";
	//x m_config_server->set_started(true);	// 为了防止网络情况异常, 造成服务端关闭连接后重置此值为2, 通讯端保证此值为1
}
Example #3
0
 virtual void close() {
   if (!closed) closed = 1;
   
   if (clientSocket->is_open()) {
     clientSocket->cancel();
     clientSocket->close();
   }
   
   if (serverSocket.is_open()) {
     serverSocket.cancel();
     serverSocket.close();
   }
 }
Example #4
0
void c_netuser::server_read(ip::tcp::socket socket_) {
	DBG_MTX(dbg_mtx, "START");
	assert(socket_.is_open());
    boost::system::error_code ec;
    DBG_MTX(dbg_mtx,"server read");
	while (!ec && !m_stop_flag) {
		char header[2] = {0, 0};
		socket_.read_some(buffer(header, 2), ec);
		if (header[0] == 'p' && header[1] == 'k') {
			send_public_key_resp(socket_);
		}
		else if (header[0] == '$' && header[1] == 't') {
			std::string coin_data = recv_coin(socket_);
			recieve_from_packet(coin_data);
		}
	}
	socket_.close();
}
Example #5
0
 // Destructor
 ~Connection()
 {
   socket.close();
 }