08 2012 档案
TCP方式的Socket
摘要:TCPServer要用TCP的客户端来测试。POCO中TCP方式的Socket有:Poco::Net::ServerSocketPoco::Net::StreamSocketPoco::Net::DialogSocketPoco::Net::SecureServerSocket ---相对于SSLPoco::Net::SecureStreamSocket ---相对于SSL 1 ServerSocket svs(0); 2 TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);...
阅读全文
UDP方式的Socket
摘要:POCO中UDP方式的Socket,主要有两种:Poco::Net::DatagramSocket、Poco::Net::MulticastSocket。1 UDPEchoServer echoServer;2 DatagramSocket ss;3 ss.connect(SocketAddress("localhost", echoServer.port()));//连接4 int n = ss.sendBytes("hello", 5);//发送5 char buffer...
阅读全文
Applications框架(翻译官网pdf)
摘要:Applications with POCO1、POCO应用程序框架,支持以下几种需求: (1)命令行参数处理;(2)配置文件;(3)初始化和关闭;(4)日志。2、POCO支持以下两种类型的应用程序:命令行应用程序和服务器应用程序。Application Subsystems3、一个应用程序由不同的subsystems组成; Subsystems可以帮助我们初始化和关闭应用程序; 当应用程序被初始化后,所有注册的subsystems也被初始化; 当应用程序被关闭后,所有注册的subsystems也被关闭;The Subsystem Class (Subsystem类)4、Subsyste...
阅读全文
跨平台---tcpclient与tcpserver
摘要:1、tcpclient(Linux)1 SocketAddress sa("192.168.20.43", 7000);2 StreamSocket ss(sa);3 int n = ss.sendBytes("hello", 5);4 char buffer[256];5 n = ss.receiveBytes(buffer, sizeof(buffer)...
阅读全文
TCPServer框架(翻译官网pdf)
摘要:1、Poco::Net::TCPServer实现一个多线程的TCP 服务器。2、服务器使用一个ServerSocket接收请求的连接,服务器使连接保持以队列形式。3、正在运行的线程从队列中取出连接然后处理它们;运行的线程会自动调整,依赖于队列中等待的连接数量。4、TCPServer创建它自己的线程,接受连接,然后把它们放到队列中。5、TCPServer使用TCPServerConnection对象来处理一个连接。你必须要创建自己的TCPServerConnection子类,工厂也一样。 工厂对象通过构造TCPServer来创建。6、你的TCPServerConnection 子类必须要重载ru
阅读全文
Poco学习资料
摘要:学习网址:1、http://www.cppblog.com/richbirdandy/archive/2010/09/10/123994.html一篇博客:Poco::TCPServer框架解析2、http://pocoproject.org/documentation/index.html POCO官网(源码下载、PDF、文档、社区)3、http://www.libpoco.com/site/info/ Poco C++ Library 助力C++开发(POCO库中文编程参考指南)4、http://blog.csdn.net/poechant/article/details/7484781
阅读全文
跨平台---udpclient与udpserver
摘要:1、udpclient(Linux)1 /*UDP client*/2 DatagramSocket ss;3 ss.connect(SocketAddress("192.168.20.43", 6000));4 int n = ss.sendBytes("hello", 5);//发送5 char buffer[256];6 n = ss.receiveBytes(buffer, sizeof(buffe...
阅读全文
本地---tcpserver与tcpclient
摘要:1、tcpserver1 ServerSocket svs(6000);//绑定端口开始监听2 TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);3 srv.start();2、tcpclient1 SocketAddress sa("localhost", svs.address().port());2 StreamSocket ss1(sa);3 ss1.sendBytes("hello", 5);4 cha...
阅读全文
本地---udpserver与udpclient
摘要:1、udpserver1 UDPEchoServer echoserver(SocketAddress("localhost",6000));2 echoserver.run();2、udpclient1 UDPEchoServer echoServer;2 DatagramSocket ss;3 ss.connect(SocketAddress("localhost", echoServer.port()));//连接4 int n = ss.sendBytes("hello", 5);//发送5 ...
阅读全文
operator(3)赋值例子
摘要:1 #include "stdafx.h" 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 class Test 7 { 8 public: 9 Test():mValue(2),mName("karen")10 {11 }12 Test(string x,int y)13 {14 mName = x;15 mValue = y;16 }17 ~Test()18 {19 }20 int getVal...
阅读全文
operator(2)输入输出与比较例子
摘要:1 #include "stdafx.h" 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 class Test 7 { 8 public: 9 Test():mValue(2),mName("karen")10 {11 }12 Test(string x,int y)13 {14 mName = x;15 mValue = y;16 }17 ~Test()18 {19 }20 friend ...
阅读全文
operator(1)算术与比较例子
摘要:1 #include "stdafx.h" 2 #include <iostream> 3 #include <math.h> 4 using namespace std; 5 class Room 6 { 7 public: 8 Room() 9 {10 }11 ~Room()12 {13 }14 void setHeight(double ht)15 {16 value = ht;17 }18 double getHeight()19 {20 return (value...
阅读全文
函数中的static变量
摘要:1、只在进入和退出变量作用域之间维护变量的值,静态变量的一种通常用法是“记住”是否已经为一个函数完成过特定的初始化。第一次调用performTask(),inited值为false;第二次调用performTask()时,inited值为true;因为当程序加载时,就已为其分配内存空间。代码例子如下: 1 #include "stdafx.h" 2 #include <iostream> 3 4 void performTask() 5 { 6 static bool inited = false; 7 if(!inited) 8 { 9 std::cout&l
阅读全文
类模板与类方法模板
摘要:1 // TemplateTest.cpp : 定义控制台应用程序的入口点。 2 3 4 #include "stdafx.h" 5 #include <iostream> 6 /*非模板定义类*/ 7 class NewTest 8 { 9 public: 10 NewTest(int t) 11 { 12 mOut = t; 13 } 14 15 virtual int action(int mIn) 16 { 17 mRes = mIn + mOut; 18 return (mRes...
阅读全文
const方法
摘要:1、先看下一个类Test.h 1 #define PI 3.14159 2 const int NUM = 3;//定义常量 3 class Test 4 { 5 public: 6 Test(); 7 virtual ~Test(); 8 virtual void action(const int input);//保护,防止意外修改 9 int getstate() const;10 const MyClass istate();11 private:12 static int mLay;13 ...
阅读全文
static--静态方法与静态成员
摘要:1、Test.h 1 class Test 2 { 3 public: 4 Test(); 5 virtual ~Test(); 6 virtual void action(); 7 static virtual void go(); 8 private: 9 static int mLay;10 int mOut;11 12 };此处,static 与 virtual不能共用,此时这里去掉virtual关键字。2、Test.h 1 class Test 2 { 3 public: 4 Test(...
阅读全文
Sphinx应用程序编写
摘要:Pocketsphinx API 核心理念 Pocketsphinx API 被设计是为了减轻编写语音识别功能应用程序。由于使用抽象类,所以在源代码和二进制文件兼容方面,更能保持稳定。因为它完全可重入,所以在同一进程中拥有多个编码器也不会出现问题。在运行时,新的语言模型的接口(在sphinxbase)支持线性多模型插值。它能大幅度减少代码量而且能明显减少内存消耗。相关文档见:http://cmusphinx.sourceforge.net/api/pocketsphinx/基本用法(hello world)你需要知道几个关键的点如何使用应用程序接口(API):命令行通过外部<cmd_ln
阅读全文
浙公网安备 33010602011771号