gusucode.com > 它是一个c_s网络编程框架源码程序 > st_asio_wrapper/asio_client/asio_client.cpp

    
//configuration
#define SERVER_PORT		9527
#define FORCE_TO_USE_MSG_RECV_BUFFER //force to use the msg recv buffer
//configuration

#include "../include/st_asio_wrapper_client.h"
using namespace st_asio_wrapper;

#define QUIT_COMMAND	"quit"

int main() {
	std::string str;
	st_client client;
	//there is no corresponding echo client demo as server endpoint
	//because echo server with echo client made dead loop, and occupy almost all the network resource

//	client.set_server_addr(SERVER_PORT, "::1"); //ipv6
//	client.set_server_addr(SERVER_PORT, "127.0.0.1"); //ipv4
	client.start_service();
	while(client.is_running())
	{
		std::cin >> str;
		if (str == QUIT_COMMAND)
			client.stop_service();
		else
			client.send_msg(str);
	}

	return 0;
}

//restore configuration
#undef SERVER_PORT
#undef FORCE_TO_USE_MSG_RECV_BUFFER //force to use the msg recv buffer
//restore configuration