コード例 #1
0
ファイル: channel_client.cpp プロジェクト: dawnbreaks/arch
int main(int argc, char** argv)
{
    if (argc != 2)
    {
        printf("Need one arg for this programme.");
        return -1;
    }
    int total = atoi(argv[1]);
    printf("Total:%d\n", total);
    ChannelService service;
    ClientSocketChannel* client = service.NewClientSocketChannel();
    ChannelOptions ops;
    ops.user_write_buffer_water_mark = 8192;
    ops.user_write_buffer_flush_timeout_mills = 1;

    SocketHostAddress address("127.0.0.1", 48100);
    SocketUnixAddress unix_address("./server.unix");
    SocketHostAddress local("127.0.0.1", 5678);
    SocketUnixAddress local_unix_address("./client.unix");
    client->Bind(&local_unix_address);
    client->Connect(&unix_address);
    client->Configure(ops);
    client->GetPipeline().AddLast("decoder", new DelimiterBasedFrameDecoder(8192, CommonDelimiters::CRLFDelimiter()));
    client->GetPipeline().AddLast("default", new ClientHandler(
            total));

    uint64 start = get_current_epoch_millis();
    arch::logging::Logger* logger = arch::logging::LoggerFactory::GetDevelopLogger();
    logger->SetLevel(arch::logging::INFO_LOG_LEVEL);
    service.Start(true);
    uint64 end = get_current_epoch_millis();
    printf("Cost %llums for total %d send/recv transaction.\n", (end - start), total);
    return 1;
}
コード例 #2
0
ファイル: channel_server.cpp プロジェクト: dawnbreaks/arch
int main(int argc, char** argv)
{
	//    if (argc != 2)
	//    {
	//        printf("Nedd one arg for this programme.");
	//        return -1;
	//    }
	//    int total = atoi(argv[1]);
	//    printf("Total:%d\n", total);
	ChannelService service;
	ServerSocketChannel* server = service.NewServerSocketChannel();
	ChannelOptions ops;
	ops.user_write_buffer_water_mark = 8192;
	ops.user_write_buffer_flush_timeout_mills = 1;


	SocketHostAddress address("192.168.56.101", 48100);
	//SocketHostAddress local("0.0.0.0", 20001);
	SocketUnixAddress unixLocal("./server.unix");
	server->Bind(&unixLocal);
	server->Configure(ops);
	//client->Connect(&address);
	//client->Configure(ops);
	//client->GetPipeline().AddLast("decoder", new DelimiterBasedFrameDecoder(8192, CommonDelimiters::CRLFDelimiter()));
	ServerHandler handler;
	//server->GetPipeline().AddLast("default", new ServerHandler());
	server->SetChannelPipelineInitializor(pipelineInit, &handler);
	server->SetChannelPipelineFinalizer(pipelineFinalize, NULL);

	uint64 start = get_current_epoch_millis();
	arch::logging::Logger* logger =
	        arch::logging::LoggerFactory::GetDevelopLogger();
	logger->SetLevel(arch::logging::INFO_LOG_LEVEL);
	service.Start(true);
	uint64 end = get_current_epoch_millis();
	//printf("Cost %ums for total %d send/recv transaction.\n", (end - start),
	//        total);
	return 1;
}
コード例 #3
0
ファイル: channel_service.cpp プロジェクト: mrkeng/ardb
 void Run()
 {
     serv->Start();
 }