A BidirectionalFileDescriptor that also generates notifications when closed.
|
static bool | SetNonBlocking (DescriptorHandle fd) |
| Set a DescriptorHandle to non-blocking mode.
|
|
|
virtual bool | IsSocket () const =0 |
|
bool | SetNoSigPipe (DescriptorHandle fd) |
| Disable SIGPIPE for this descriptor.
|
|
◆ DataRemaining()
int ola::io::ConnectedDescriptor::DataRemaining |
( |
| ) |
const |
Find out how much data is left to read.
- Returns
- the amount of unread data for the descriptor.
◆ Receive()
int ola::io::ConnectedDescriptor::Receive |
( |
uint8_t * |
buffer, |
|
|
unsigned int |
size, |
|
|
unsigned int & |
data_read |
|
) |
| |
|
virtual |
Read data from this descriptor.
- Parameters
-
buffer | a pointer to the buffer to store new data in |
size | the size of the buffer |
data_read | a value result argument which returns the size of the data copied into the buffer. |
- Returns
- -1 on error, 0 on success.
◆ Send() [1/2]
ssize_t ola::io::ConnectedDescriptor::Send |
( |
const uint8_t * |
buffer, |
|
|
unsigned int |
size |
|
) |
| |
|
virtual |
Write a buffer to the descriptor.
- Parameters
-
buffer | a pointer to the buffer to write |
size | the number of bytes in the buffer to write |
- Returns
- the number of bytes written
◆ Send() [2/2]
ssize_t ola::io::ConnectedDescriptor::Send |
( |
IOQueue * |
data | ) |
|
|
virtual |
Write data from an IOQueue to a descriptor.
- Parameters
-
data | the IOQueue containing the data to write. Data written to the descriptor will be removed from the IOQueue. |
- Returns
- the number of bytes written.
This attempts to send as much of the IOQueue data as possible. The IOQueue may be non-empty when this completes if the descriptor buffer is full.
- Returns
- the number of bytes sent.
◆ SetOnClose()
void ola::io::ConnectedDescriptor::SetOnClose |
( |
OnCloseCallback * |
on_close | ) |
|
|
inline |
Set the callback to be run when the descriptor is closed.
- Parameters
-
on_close | the callback to run, ownership of the callback is transferred. |
◆ SetReadNonBlocking()
virtual bool ola::io::ConnectedDescriptor::SetReadNonBlocking |
( |
| ) |
|
|
inlinevirtual |
Enable on non-blocking reads..
- Returns
- true if it worked, false otherwise.
On Windows, this is only supported for sockets.
◆ TransferOnClose()
Take ownership of the on_close callback.
This method transfers ownership of the on_close callback from the socket to the caller. Often an on_close callback ends up deleting the socket that its bound to. This can cause problems because we run the destructor from within the Close() method of the same object. To avoid this when we want to call the on close handler we transfer ownership away from the socket
The documentation for this class was generated from the following files: