|
uvw
1.10.0
|
The StreamHandle handle. More...
#include <stream.hpp>


Public Member Functions | |
| void | shutdown () |
| Shutdowns the outgoing (write) side of a duplex stream. More... | |
| void | listen (int backlog=DEFAULT_BACKLOG) |
| Starts listening for incoming connections. More... | |
| template<typename S > | |
| void | accept (S &ref) |
| Accepts incoming connections. More... | |
| void | read () |
| Starts reading data from an incoming stream. More... | |
| void | stop () |
| Stops reading data from the stream. More... | |
| void | write (std::unique_ptr< char[]> data, unsigned int len) |
| Writes data to the stream. More... | |
| void | write (char *data, unsigned int len) |
| Writes data to the stream. More... | |
| template<typename S > | |
| void | write (S &send, std::unique_ptr< char[]> data, unsigned int len) |
| Extended write function for sending handles over a pipe handle. More... | |
| template<typename S > | |
| void | write (S &send, char *data, unsigned int len) |
| Extended write function for sending handles over a pipe handle. More... | |
| int | tryWrite (std::unique_ptr< char[]> data, unsigned int len) |
| Queues a write request if it can be completed immediately. More... | |
| int | tryWrite (char *data, unsigned int len) |
| Queues a write request if it can be completed immediately. More... | |
| bool | readable () const noexcept |
| Checks if the stream is readable. More... | |
| bool | writable () const noexcept |
| Checks if the stream is writable. More... | |
| bool | blocking (bool enable=false) |
| Enables or disables blocking mode for a stream. More... | |
| size_t | writeQueueSize () const noexcept |
| Gets the amount of queued bytes waiting to be sent. More... | |
Public Member Functions inherited from uvw::Handle< T, U > | |
| HandleCategory | category () const noexcept override |
| Gets the category of the handle. More... | |
| HandleType | type () const noexcept override |
| Gets the type of the handle. More... | |
| bool | active () const noexcept override |
| Checks if the handle is active. More... | |
| bool | closing () const noexcept override |
| Checks if a handle is closing or closed. More... | |
| void | close () noexcept override |
| Request handle to be closed. More... | |
| void | reference () noexcept override |
| Reference the given handle. More... | |
| void | unreference () noexcept override |
| Unreference the given handle. More... | |
| bool | referenced () const noexcept override |
| Checks if the given handle referenced. More... | |
| std::size_t | size () const noexcept |
| Returns the size of the underlying handle type. More... | |
| int | sendBufferSize () |
| Gets the size of the send buffer used for the socket. More... | |
| bool | sendBufferSize (int value) |
| Sets the size of the send buffer used for the socket. More... | |
| int | recvBufferSize () |
| Gets the size of the receive buffer used for the socket. More... | |
| bool | recvBufferSize (int value) |
| Sets the size of the receive buffer used for the socket. More... | |
| OSFileDescriptor | fileno () const |
| Gets the platform dependent file descriptor equivalent. More... | |
Public Member Functions inherited from uvw::UnderlyingType< T, U > | |
| Loop & | loop () const noexcept |
| Gets the loop from which the resource was originated. More... | |
| const U * | raw () const noexcept |
| Gets the underlying raw data structure. More... | |
| U * | raw () noexcept |
| Gets the underlying raw data structure. More... | |
Public Member Functions inherited from uvw::Emitter< T > | |
| template<typename E > | |
| Connection< E > | on (Listener< E > f) |
| Registers a long-lived listener with the event emitter. More... | |
| template<typename E > | |
| Connection< E > | once (Listener< E > f) |
| Registers a short-lived listener with the event emitter. More... | |
| template<typename E > | |
| void | erase (Connection< E > conn) noexcept |
| Disconnects a listener from the event emitter. More... | |
| template<typename E > | |
| void | clear () noexcept |
| Disconnects all the listeners for the given event type. | |
| void | clear () noexcept |
| Disconnects all the listeners. | |
| template<typename E > | |
| bool | empty () const noexcept |
| Checks if there are listeners registered for the specific event. More... | |
| bool | empty () const noexcept |
| Checks if there are listeners registered with the event emitter. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from uvw::UnderlyingType< T, U > | |
| template<typename... Args> | |
| static std::shared_ptr< T > | create (Args &&... args) |
| Creates a new resource of the given type. More... | |
The StreamHandle handle.
Stream handles provide an abstraction of a duplex communication channel. StreamHandle is an intermediate type, uvw provides three stream implementations: TcpHandle, PipeHandle and TTYHandle.
Definition at line 130 of file stream.hpp.
|
inline |
Accepts incoming connections.
This call is used in conjunction with listen() to accept incoming connections. Call this function after receiving a ListenEvent event to accept the connection. Before calling this function, the submitted handle must be initialized.
An ErrorEvent event will be emitted in case of errors.
When the ListenEvent event is emitted it is guaranteed that this function will complete successfully the first time. If you attempt to use it more than once, it may fail.
It is suggested to only call this function once per ListenEvent event.
Note: both the handles must be running on the same loop.
| ref | An initialized handle to be used to accept the connection. |
Definition at line 220 of file stream.hpp.
|
inline |
Enables or disables blocking mode for a stream.
When blocking mode is enabled all writes complete synchronously. The interface remains unchanged otherwise, e.g. completion or failure of the operation will still be reported through events which are emitted asynchronously.
See the official documentation for further details.
| enable | True to enable blocking mode, false otherwise. |
Definition at line 445 of file stream.hpp.
|
inline |
Starts listening for incoming connections.
When a new incoming connection is received, a ListenEvent event is emitted.
An ErrorEvent event will be emitted in case of errors.
| backlog | Indicates the number of connections the kernel might queue, same as listen(2). |
Definition at line 197 of file stream.hpp.
|
inline |
Starts reading data from an incoming stream.
A DataEvent event will be emitted several times until there is no more data to read or stop() is called.
An EndEvent event will be emitted when there is no more data to read.
Definition at line 231 of file stream.hpp.
|
inlinenoexcept |
Checks if the stream is readable.
Definition at line 418 of file stream.hpp.
|
inline |
Shutdowns the outgoing (write) side of a duplex stream.
It waits for pending write requests to complete. The handle should refer to a initialized stream.
A ShutdownEvent event will be emitted after shutdown is complete.
Definition at line 176 of file stream.hpp.
|
inline |
Stops reading data from the stream.
This function is idempotent and may be safely called on a stopped stream.
Definition at line 240 of file stream.hpp.
|
inline |
Queues a write request if it can be completed immediately.
Same as write(), but won’t queue a write request if it can’t be completed immediately.
An ErrorEvent event will be emitted in case of errors.
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 379 of file stream.hpp.
|
inline |
Queues a write request if it can be completed immediately.
Same as write(), but won’t queue a write request if it can’t be completed immediately.
An ErrorEvent event will be emitted in case of errors.
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 402 of file stream.hpp.
|
inlinenoexcept |
Checks if the stream is writable.
Definition at line 426 of file stream.hpp.
|
inline |
Writes data to the stream.
Data are written in order. The handle takes the ownership of the data and it is in charge of delete them.
A WriteEvent event will be emitted when the data have been written.
An ErrorEvent event will be emitted in case of errors.
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 256 of file stream.hpp.
|
inline |
Writes data to the stream.
Data are written in order. The handle doesn't take the ownership of the data. Be sure that their lifetime overcome the one of the request.
A WriteEvent event will be emitted when the data have been written.
An ErrorEvent event will be emitted in case of errors.
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 283 of file stream.hpp.
|
inline |
Extended write function for sending handles over a pipe handle.
The pipe must be initialized with ipc == true.
send must be a TcpHandle or PipeHandle handle, which is a server or a connection (listening or connected state). Bound sockets or pipes will be assumed to be servers.
The handle takes the ownership of the data and it is in charge of delete them.
A WriteEvent event will be emitted when the data have been written.
An ErrorEvent wvent will be emitted in case of errors.
| send | The handle over which to write data. |
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 318 of file stream.hpp.
|
inline |
Extended write function for sending handles over a pipe handle.
The pipe must be initialized with ipc == true.
send must be a TcpHandle or PipeHandle handle, which is a server or a connection (listening or connected state). Bound sockets or pipes will be assumed to be servers.
The handle doesn't take the ownership of the data. Be sure that their lifetime overcome the one of the request.
A WriteEvent event will be emitted when the data have been written.
An ErrorEvent wvent will be emitted in case of errors.
| send | The handle over which to write data. |
| data | The data to be written to the stream. |
| len | The lenght of the submitted data. |
Definition at line 353 of file stream.hpp.
|
inlinenoexcept |
Gets the amount of queued bytes waiting to be sent.
Definition at line 453 of file stream.hpp.
1.8.13