/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <chrono> #include <memory> #include <folly/Optional.h> #include <folly/io/IOBuf.h> #include <folly/io/IOBufIovecBuilder.h> #include <folly/io/async/AsyncSocketBase.h> #include <folly/io/async/AsyncTransportCertificate.h> #include <folly/io/async/DelayedDestruction.h> #include <folly/io/async/EventBase.h> #include <folly/io/async/WriteFlags.h> #include <folly/portability/OpenSSL.h> #include <folly/portability/SysUio.h> #include <folly/ssl/OpenSSLPtrTypes.h> namespace folly { class AsyncSocketException; class EventBase; class SocketAddress; class AsyncReader { … }; class AsyncWriter { … }; /** * AsyncTransport defines an asynchronous API for bidirectional streaming I/O. * * This class provides an API to for asynchronously waiting for data * on a streaming transport, and for asynchronously sending data. * * The APIs for reading and writing are intentionally asymmetric. Waiting for * data to read is a persistent API: a callback is installed, and is notified * whenever new data is available. It continues to be notified of new events * until it is uninstalled. * * AsyncTransport does not provide read timeout functionality, because it * typically cannot determine when the timeout should be active. Generally, a * timeout should only be enabled when processing is blocked waiting on data * from the remote endpoint. For server-side applications, the timeout should * not be active if the server is currently processing one or more outstanding * requests on this transport. For client-side applications, the timeout * should not be active if there are no requests pending on the transport. * Additionally, if a client has multiple pending requests, it will ususally * want a separate timeout for each request, rather than a single read timeout. * * The write API is fairly intuitive: a user can request to send a block of * data, and a callback will be informed once the entire block has been * transferred to the kernel, or on error. AsyncTransport does provide a send * timeout, since most callers want to give up if the remote end stops * responding and no further progress can be made sending the data. */ class AsyncTransport : public DelayedDestruction, public AsyncSocketBase, public AsyncReader, public AsyncWriter { … }; AsyncTransportWrapper; } // namespace folly