proxygen
folly::AsyncServerSocket::AcceptCallback Class Referenceabstract

#include <AsyncServerSocket.h>

Inheritance diagram for folly::AsyncServerSocket::AcceptCallback:
fizz::server::test::FizzTestServer folly::SSLServerAcceptCallbackBase folly::test::TestAcceptCallback folly::ZeroCopyTestServer wangle::Acceptor folly::ConnectTimeoutCallback folly::HandshakeErrorCallback folly::HandshakeTimeoutCallback folly::SSLServerAcceptCallback proxygen::HTTPAcceptor TestAcceptor TestAcceptor wangle::ServerAcceptor< Pipeline > wangle::TestableAcceptor

Public Member Functions

virtual ~AcceptCallback ()=default
 
virtual void connectionAccepted (int fd, const SocketAddress &clientAddr) noexcept=0
 
virtual void acceptError (const std::exception &ex) noexcept=0
 
virtual void acceptStarted () noexcept
 
virtual void acceptStopped () noexcept
 

Detailed Description

Definition at line 138 of file AsyncServerSocket.h.

Constructor & Destructor Documentation

virtual folly::AsyncServerSocket::AcceptCallback::~AcceptCallback ( )
virtualdefault

Member Function Documentation

virtual void folly::AsyncServerSocket::AcceptCallback::acceptError ( const std::exception &  ex)
pure virtualnoexcept

acceptError() is called if an error occurs while accepting.

The AcceptCallback will remain installed even after an accept error, as the errors are typically somewhat transient, such as being out of file descriptors. The server socket must be explicitly stopped if you wish to stop accepting after an error.

Parameters
exAn exception representing the error.

Implemented in wangle::Acceptor, folly::ZeroCopyTestServer, folly::test::TestAcceptCallback, folly::SSLServerAcceptCallbackBase, and fizz::server::test::FizzTestServer.

Referenced by folly::AsyncServerSocket::dispatchError(), and folly::AsyncServerSocket::RemoteAcceptor::messageAvailable().

virtual void folly::AsyncServerSocket::AcceptCallback::acceptStarted ( )
inlinevirtualnoexcept

acceptStarted() will be called in the callback's EventBase thread after this callback has been added to the AsyncServerSocket.

acceptStarted() will be called before any calls to connectionAccepted() or acceptError() are made on this callback.

acceptStarted() makes it easier for callbacks to perform initialization inside the callback thread. (The call to addAcceptCallback() must always be made from the AsyncServerSocket's primary EventBase thread. acceptStarted() provides a hook that will always be invoked in the callback's thread.)

Note that the call to acceptStarted() is made once the callback is added, regardless of whether or not the AsyncServerSocket is actually accepting at the moment. acceptStarted() will be called even if the AsyncServerSocket is paused when the callback is added (including if the initial call to startAccepting() on the AsyncServerSocket has not been made yet).

Reimplemented in folly::test::TestAcceptCallback.

Definition at line 194 of file AsyncServerSocket.h.

Referenced by folly::AsyncServerSocket::addAcceptCallback().

194 {}
virtual void folly::AsyncServerSocket::AcceptCallback::acceptStopped ( )
inlinevirtualnoexcept

acceptStopped() will be called when this AcceptCallback is removed from the AsyncServerSocket, or when the AsyncServerSocket is destroyed, whichever occurs first.

No more calls to connectionAccepted() or acceptError() will be made after acceptStopped() is invoked.

Reimplemented in wangle::Acceptor, folly::test::TestAcceptCallback, and wangle::ServerAcceptor< Pipeline >.

Definition at line 204 of file AsyncServerSocket.h.

Referenced by folly::AsyncServerSocket::removeAcceptCallback().

204 {}
virtual void folly::AsyncServerSocket::AcceptCallback::connectionAccepted ( int  fd,
const SocketAddress clientAddr 
)
pure virtualnoexcept

connectionAccepted() is called whenever a new client connection is received.

The AcceptCallback will remain installed after connectionAccepted() returns.

Parameters
fdThe newly accepted client socket. The AcceptCallback assumes ownership of this socket, and is responsible for closing it when done. The newly accepted file descriptor will have already been put into non-blocking mode.
clientAddrA reference to a SocketAddress struct containing the client's address. This struct is only guaranteed to remain valid until connectionAccepted() returns.

Implemented in wangle::Acceptor, folly::ZeroCopyTestServer, folly::test::TestAcceptCallback, folly::SSLServerAcceptCallbackBase, and fizz::server::test::FizzTestServer.

Referenced by folly::AsyncServerSocket::dispatchSocket(), and folly::AsyncServerSocket::RemoteAcceptor::messageAvailable().


The documentation for this class was generated from the following file: