Abstract asynchronous transport backed by a socket.
Synopsis
Declared in <folly/io/async/AsyncSocketTransport.h>
class AsyncSocketTransport
: public AsyncTransport
Base Classes
Name |
Description |
AsyncTransport defines an asynchronous API for bidirectional streaming I/O. |
Types
Name |
Description |
Callback class to signal changes in the transport's internal buffers. |
|
Callback invoked on the outcome of a connection attempt. |
|
Helper class to allow DelayedDestruction classes to be used with std::shared_ptr. |
|
Classes should create a DestructorGuard object on the stack in any function that may invoke callback functions. |
|
This smart pointer is a convenient way to manage a concrete DelayedDestructorBase child. It can replace the equivalent raw pointer and provide automatic memory management. |
|
Parameters controlling receive‐side zero‐copy. |
|
Callback interface used to receive data read from the transport. |
|
Callback invoked to release ownership of an IOBuf after a write. |
|
Callback class to signal when a transport that did not have replay protection gains replay protection. This is needed for 0‐RTT security protocols. |
|
Callback interface used to report the result of a write. |
Type Aliases
Name |
Description |
Options for binding a socket before connecting. The two alternatives are mutually exclusive: ‐ SocketAddress: bind to a local address before connecting. ‐ NetworkSocket: use a pre‐bound (or pre‐created) socket fd. Ownership of the fd is transferred to the AsyncSocketTransport. |
|
Owning pointer type that respects the transport's deferred destructor. |
|
Predicate deciding whether a given buffer should use zero‐copy writes. |
Member Functions
Name |
Description |
|
Deleted copy assignment operator. |
|
Attach the transport to a EventBase. |
|
Caches the local and peer addresses of the socket. |
|
If a connect request is in‐flight, cancels it and closes the socket immediately. Otherwise, this is a no‐op. |
|
Close the transport. |
|
Close the transport immediately. |
|
Reset the transport immediately. |
|
Initiates an asynchronous connection to the given address. |
|
Determine if transport is connected to the endpoint |
|
destroy() requests destruction of the object. |
|
Detach the transport from its EventBase. |
|
Disables transparent TLS handling on the socket. |
|
Releases the cached peer certificate. |
|
Releases the cached self certificate. |
|
Enables TCP Fast Open on the socket. |
|
Determine if an error has occurred with this transport. |
|
Store the local address of this transport in the given SocketAddress. |
|
Return the number of allocated bytes buffered to be written later. |
|
Calculates the total number of bytes that are currently buffered in the transport to be written later. |
|
Return the number of application‐level bytes received. |
|
Return the number of application‐level bytes written. |
|
Return the application protocol being used by the underlying transport protocol. This is useful for transports which are used to tunnel other protocols. |
Returns whether destruction has been requested but deferred. |
|
|
Returns the event base this socket is attached to. |
|
Produce exported keying material for this transport. |
|
|
|
Returns the NAPI id associated with the socket. |
|
Returns the underlying network socket handle. |
Get the address of the remote endpoint to which this transport is connected. |
|
|
Returns the peer's certificate, or nullptr if none is set. |
|
Return whether receive‐side zero‐copy is enabled. |
|
Return the number of raw bytes buffered to be written later. |
|
Return the number of raw bytes received from the underlying transport. |
|
Return the number of raw bytes written to the underlying transport. |
|
Return the currently installed read callback. |
|
Returns the name of the security protocol being used. |
|
Returns this endpoint's certificate, or nullptr if none is set. |
|
Get the send timeout. |
|
Returns whether TCP Fast Open succeeded for this connection. |
|
|
|
AsyncTransports may wrap other AsyncTransport. This returns the transport that is wrapped. It returns nullptr if there is no wrapped transport. |
|
|
|
Return whether zero‐copy writes are enabled. |
|
Determine if transport is open and ready to read or write. |
|
Returns whether the peer has hung up the connection. |
|
Determine if the transport can be detached. |
|
Return whether end‐of‐record tracking is enabled. |
|
Determine if the there is pending data on the transport. |
|
False if the transport does not have replay protection, but will in the future. |
|
Determine if the transport is readable or not. |
|
Enable or disable end‐of‐record tracking. |
|
Enables or disables Nagle's algorithm on the socket. |
Stores the peer's certificate for later retrieval. |
|
|
Provides data to be treated as if it had already been received. |
|
Enable or disable receive‐side zero‐copy using the given parameters. |
|
Install the read callback that will receive read events. |
|
Set the ReplaySafeCallback on this transport. |
Stores this endpoint's certificate for later retrieval. |
|
|
Set the send timeout. |
|
Sets a socket option on the underlying socket. |
|
Enable or disable zero‐copy writes. |
|
Set the predicate deciding when zero‐copy writes are used. |
|
Set the minimum write size, in bytes, for using zero‐copy writes. |
|
Perform a half‐shutdown of the write side of the transport. |
|
Perform a half‐shutdown of the write side of the transport. |
|
Take any data received before a read callback was installed. |
Exchange the underlying transport of type T with the given one. |
|
|
Exchange the directly wrapped transport with the given one. |
|
Determine if the transport is writable or not. |
|
If you supply a non‐null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation. |
|
If you supply a non‐null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation. |
|
If you supply a non‐null WriteCallback, exactly one of writeSuccess() or writeErr() will be invoked when the write completes. If you supply the same WriteCallback object for multiple write() calls, it will be invoked exactly once per call. The only way to cancel outstanding write requests is to close the socket (e.g., with closeNow() or shutdownWriteNow()). When closing the socket this way, writeErr() will still be invoked once for each outstanding write operation. |
Static Member Functions
Name |
Description |
Returns a wildcard address usable as a default bind target. |
Protected Member Functions
Name |
Description |
|
Destroys the transport. |
Get the number of DestructorGuards currently protecting this object. |
|
|
Implement onDelayedDestroy in subclasses. onDelayedDestroy() is invoked when the object is potentially being destroyed. |
Protected Data Members
Name |
Description |
Cached peer certificate; subclasses may populate it on first access. |
|
Cached self certificate; subclasses may populate it on first access. |
Derived Classes
Name |
Description |
An asynchronous socket. |
Created with MrDocs