dgramtwowaystream.h
来自「一个语言识别引擎」· C头文件 代码 · 共 99 行
H
99 行
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
/*
* Copyright (C) 2006 Paul Fitzpatrick
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*
*/
#ifndef _YARP2_DGRAMTWOWAYSTREAM_
#define _YARP2_DGRAMTWOWAYSTREAM_
#include <yarp/TwoWayStream.h>
#include <yarp/IOException.h>
#include <yarp/ManagedBytes.h>
#include <ace/SOCK_Dgram.h>
namespace yarp {
class DgramTwoWayStream;
}
/**
* A stream abstraction for datagram communication. It supports UDP and
* MCAST. This class is not concerned with making the stream reliable.
*/
class yarp::DgramTwoWayStream : public TwoWayStream, public InputStream, public OutputStream {
public:
DgramTwoWayStream() {
closed = false;
reader = false;
writer = false;
dgram = NULL;
happy = false;
bufferAlerted = bufferAlertNeeded = false;
}
virtual void open(const Address& remote);
virtual void open(const Address& local, const Address& remote);
virtual void join(const Address& group, bool sender);
virtual ~DgramTwoWayStream();
virtual InputStream& getInputStream() {
return *this;
}
virtual OutputStream& getOutputStream() {
return *this;
}
virtual const Address& getLocalAddress() {
return localAddress;
}
virtual const Address& getRemoteAddress() {
return remoteAddress;
}
virtual void interrupt();
virtual void close();
virtual int read(const Bytes& b);
virtual void write(const Bytes& b);
virtual void flush();
virtual bool isOk();
virtual void reset();
virtual void beginPacket();
virtual void endPacket();
private:
bool closed, reader, writer;
ACE_SOCK_Dgram *dgram;
ACE_INET_Addr localHandle, remoteHandle;
Address localAddress, remoteAddress;
ManagedBytes readBuffer, writeBuffer;
int readAt, readAvail, writeAvail, pct;
bool happy;
bool bufferAlertNeeded;
bool bufferAlerted;
void allocate();
void configureSystemBuffers();
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?