proxygen
|
#include <AsyncSocketTest2.h>
Classes | |
struct | EventInfo |
Public Types | |
enum | EventType { TYPE_START, TYPE_ACCEPT, TYPE_ERROR, TYPE_STOP } |
typedef std::deque< EventInfo > | EventList |
Public Member Functions | |
TestAcceptCallback () | |
std::deque< EventInfo > * | getEvents () |
void | setConnectionAcceptedFn (const std::function< void(int, const folly::SocketAddress &)> &fn) |
void | setAcceptErrorFn (const std::function< void(const std::exception &)> &fn) |
void | setAcceptStartedFn (const std::function< void()> &fn) |
void | setAcceptStoppedFn (const std::function< void()> &fn) |
void | connectionAccepted (int fd, const folly::SocketAddress &clientAddr) noexceptoverride |
void | acceptError (const std::exception &ex) noexceptoverride |
void | acceptStarted () noexceptoverride |
void | acceptStopped () noexceptoverride |
Public Member Functions inherited from folly::AsyncServerSocket::AcceptCallback | |
virtual | ~AcceptCallback ()=default |
Private Attributes | |
std::function< void(int, const folly::SocketAddress &)> | connectionAcceptedFn_ |
std::function< void(const std::exception &)> | acceptErrorFn_ |
std::function< void()> | acceptStartedFn_ |
std::function< void()> | acceptStoppedFn_ |
std::deque< EventInfo > | events_ |
Helper AcceptCallback class for the test code It records the callbacks that were invoked, and also supports calling generic std::function objects in each callback.
Definition at line 142 of file AsyncSocketTest2.h.
typedef std::deque<EventInfo> folly::test::TestAcceptCallback::EventList |
Definition at line 158 of file AsyncSocketTest2.h.
Enumerator | |
---|---|
TYPE_START | |
TYPE_ACCEPT | |
TYPE_ERROR | |
TYPE_STOP |
Definition at line 144 of file AsyncSocketTest2.h.
|
inline |
Definition at line 160 of file AsyncSocketTest2.h.
|
inlineoverridevirtualnoexcept |
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.
ex | An exception representing the error. |
Implements folly::AsyncServerSocket::AcceptCallback.
Definition at line 193 of file AsyncSocketTest2.h.
|
inlineoverridevirtualnoexcept |
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 from folly::AsyncServerSocket::AcceptCallback.
Definition at line 200 of file AsyncSocketTest2.h.
|
inlineoverridevirtualnoexcept |
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 from folly::AsyncServerSocket::AcceptCallback.
Definition at line 207 of file AsyncSocketTest2.h.
|
inlineoverridevirtualnoexcept |
connectionAccepted() is called whenever a new client connection is received.
The AcceptCallback will remain installed after connectionAccepted() returns.
fd | The 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. |
clientAddr | A reference to a SocketAddress struct containing the client's address. This struct is only guaranteed to remain valid until connectionAccepted() returns. |
Implements folly::AsyncServerSocket::AcceptCallback.
Definition at line 184 of file AsyncSocketTest2.h.
|
inline |
Definition at line 166 of file AsyncSocketTest2.h.
Referenced by serverSocketSanityTest(), and TEST().
|
inline |
Definition at line 174 of file AsyncSocketTest2.h.
Referenced by serverSocketSanityTest(), and TEST().
|
inline |
Definition at line 177 of file AsyncSocketTest2.h.
Referenced by TEST().
|
inline |
Definition at line 180 of file AsyncSocketTest2.h.
Referenced by TEST().
|
inline |
Definition at line 170 of file AsyncSocketTest2.h.
Referenced by serverSocketSanityTest(), and TEST().
|
private |
Definition at line 217 of file AsyncSocketTest2.h.
|
private |
Definition at line 218 of file AsyncSocketTest2.h.
|
private |
Definition at line 219 of file AsyncSocketTest2.h.
|
private |
Definition at line 216 of file AsyncSocketTest2.h.
|
private |
Definition at line 221 of file AsyncSocketTest2.h.