38 #include <netinet/in.h>
86 UDPPort (std::map<std::string, std::string> options);
96 ssize_t
Read (
void *
const buffer,
size_t count);
98 ssize_t
ReadFull (
void *
const buffer,
size_t count);
100 ssize_t
ReadUntil (
void *
const buffer,
size_t count, uint8_t terminator);
107 ssize_t
SkipUntil (uint8_t terminator,
unsigned int count);
113 ssize_t
Write (
const void *
const buffer,
size_t count);
131 #if defined (FLEXIPORT_HAVE_GETADDRINFO)
132 struct sockaddr _destSockAddr;
134 struct sockaddr_in _destSockAddr;
141 unsigned int _destPort;
143 unsigned int _recvPort;
146 void CheckPort (
bool read);
148 bool ProcessOption (
const std::string &option,
const std::string &value);
152 void OpenReceiver ();
153 void CloseReceiver ();
154 typedef enum {TIMED_OUT, DATA_AVAILABLE, CAN_WRITE} WaitStatus;
155 WaitStatus WaitForDataOrTimeout ();
156 bool IsDataAvailable ();
157 WaitStatus WaitForWritableOrTimeout ();
158 void SetSocketBlockingFlag ();
An object used to represent timeouts.
void SetCanRead(bool canRead)
Set the read permissions of the port.
std::string GetStatus() const
Get the status of the port (type, device, etc).
ssize_t ReadFull(void *const buffer, size_t count)
Read the requested quantity of data from the port.
ssize_t BytesAvailable()
Get the number of bytes waiting to be read at the port. Returns immediatly.
bool IsOpen() const
Check if the port is open.
ssize_t BytesAvailableWait()
Get the number of bytes waiting after blocking for the timeout.
ssize_t ReadUntil(void *const buffer, size_t count, uint8_t terminator)
Read data until a specified termination byte is received.
ssize_t Skip(size_t count)
Dump data until the specified number of bytes have been read.
void Open()
Open the port.
void Close()
Close the port.
UDPPort(std::map< std::string, std::string > options)
void SetTimeout(Timeout timeout)
Set the timeout value in milliseconds.
ssize_t SkipUntil(uint8_t terminator, unsigned int count)
Read and dump data until the specified termination character has been seen count times.
void Flush()
Flush the port's input and output buffers, discarding all data.
void SetCanWrite(bool canWrite)
Set the write permissions of the port.
ssize_t Write(const void *const buffer, size_t count)
Write data to the port.
ssize_t Read(void *const buffer, size_t count)
Read from the port.
void Drain()
Drain the port's input and output buffers.
ssize_t ReadStringUntil(std::string &buffer, char terminator)
Read a string until the specified termination character is received.