UDPTransport Class
(CDP::IO::UDPTransport)The UDPTransport is a class used to simplify the handling of configurable UDP communication in an IOServer. More...
Header: | #include <IO/UDPTransport.h> |
Inherits: | NetworkTransport and UdpSendReceive |
Public Functions
UDPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > readCallbackHandler) |
Reimplemented Public Functions
virtual void | Close() override |
virtual std::string | GetNodeTypeName() const override |
virtual bool | IsError() override |
virtual bool | IsOpen() const override |
virtual bool | Open(Transport::OpenMode mode) override |
virtual unsigned int | Read(char *data, unsigned int length, double timeout = 0.0) override |
virtual unsigned int | Write(const char *data, unsigned int length, double timeout = 0.0) override |
- 10 public functions inherited from CDP::IO::NetworkTransport
- 28 public functions inherited from UdpSendReceive
- 12 public functions inherited from CDP::IO::Transport
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Additional Inherited Members
- 1 static public member inherited from CDP::IO::Transport
- 3 protected functions inherited from UdpSendReceive
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 12 protected variables inherited from UdpSendReceive
Detailed Description
The UDPTransport is a class used to simplify the handling of configurable UDP communication in an IOServer.
See also NetworkTransport, Transport, and TCPTransport.
Member Function Documentation
UDPTransport::UDPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > readCallbackHandler)
Constructs UDPTransport and sets callbackHandler
[override virtual]
void UDPTransport::Close()
Reimplemented from Transport::Close().
Colses the socket
[override virtual]
std::string UDPTransport::GetNodeTypeName() const
Reimplemented from ICDPNode::GetNodeTypeName().
Returns "UDPTransport"
[override virtual]
bool UDPTransport::IsError()
Reimplemented from Transport::IsError().
Returns true if there is a socket error, false if not.
[override virtual]
bool UDPTransport::IsOpen() const
Reimplemented from Transport::IsOpen().
Returns true if socket is open, false if not.
[override virtual]
bool UDPTransport::Open(Transport::OpenMode mode)
Reimplemented from Transport::Open().
Opens the socket, depending on OpenMode.
[override virtual]
unsigned int UDPTransport::Read(char *data, unsigned int length, double timeout = 0.0)
Reimplemented from Transport::Read().
Reads length bytes of data from the udp socket within timeout [seconds]. If timeout<=0.0, the timeout from the configuration is used. Returns Number of bytes read.
It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Read will block for how long it takes to read the data, or for timeout seconds, whichever comes first.
As Read() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.
[override virtual]
unsigned int UDPTransport::Write(const char *data, unsigned int length, double timeout = 0.0)
Reimplemented from Transport::Write().
Writes the packet data to the configured ip/port. Returns number of bytes written.
It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Write will block for up to timeout seconds for the output to be ready before attempting to write the data.
As Write() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.