test_upipe.h
来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C头文件 代码 · 共 77 行
H
77 行
/* -*- C++ -*- */// $Id: test_upipe.h 78769 2007-07-03 21:07:53Z shuston $#ifndef ACE_TEST_UPIPE_H#define ACE_TEST_UPIPE_H#include "ace/OS_NS_unistd.h"#include "ace/Svc_Handler.h"#include "ace/Service_Config.h"#include "ace/UPIPE_Stream.h"typedef ACE_Svc_Handler <ACE_UPIPE_STREAM, ACE_NULL_SYNCH> SVC_HANDLER;class Server_Service : public SVC_HANDLER // = TITLE // Defines the interface for a service that recvs data from its // client and writes the data to its stdout.{public: Server_Service (ACE_Thread_Manager * = 0) {} virtual int open (void *) { ACE_TRACE ("Server_Service::open"); return 0; } virtual int svc (void) { ACE_TRACE ("Server_Service::svc"); char buf[BUFSIZ]; ssize_t n; while ((n = this->peer ().recv (buf, sizeof buf)) > 0) ACE_OS::write (ACE_STDOUT, buf, n); return 0; }};class Client_Service : public SVC_HANDLER // = TITLE // Defines the interface for a service that recvs data from its // stdin and forward the data to its server.{public: Client_Service (ACE_Thread_Manager *thr_mgr = 0) : SVC_HANDLER (thr_mgr) { ACE_TRACE ("Client_Service::Client_Service"); } virtual int open (void *) { ACE_TRACE ("Client_Service::open"); return this->activate (THR_DETACHED | THR_NEW_LWP); } virtual int svc (void) { ACE_TRACE ("Client_Service::svc"); char buf[BUFSIZ]; ssize_t n; while ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) this->peer ().send (buf, n); this->peer ().close (); return 0; }};#endif /* ACE_TEST_UPIPE_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?