71 std::shared_ptr<AsyncUDPSocket>
socket,
73 std::unique_ptr<folly::IOBuf> buf,
74 bool truncated) noexcept = 0;
124 CHECK(
socket_) <<
"Need to bind before listening";
127 auto callback = listener.second;
129 listener.first->runInEventBaseThread(
130 [callback]()
mutable { callback->onListenStarted(); });
137 CHECK(
socket_) <<
"Need to bind before getting FD";
142 CHECK(
socket_) <<
"Need to bind before closing";
157 auto callback = listener.second;
159 listener.first->runInEventBaseThread(
160 [callback]()
mutable { callback->onListenPaused(); });
170 auto callback = listener.second;
172 listener.first->runInEventBaseThread(
173 [callback]()
mutable { callback->onListenResumed(); });
191 LOG(
WARNING) <<
"UDP server socket dropping packet, " 192 <<
"no listener registered";
200 auto client = clientAddress;
210 truncated]()
mutable {
219 LOG(ERROR) << ex.what();
227 auto callback = listener.second;
229 listener.first->runInEventBaseThread(
230 [callback]()
mutable { callback->onListenStopped(); });
void getAddress(SocketAddress *a) const override
std::unique_ptr< folly::IOBuf > split(size_t n)
~AsyncUDPServerSocket() override
void addListener(EventBase *evb, Callback *callback)
virtual void onListenPaused() noexcept
virtual void onDataAvailable(std::shared_ptr< AsyncUDPSocket > socket, const folly::SocketAddress &addr, std::unique_ptr< folly::IOBuf > buf, bool truncated) noexcept=0
std::pair< EventBase *, Callback * > Listener
std::shared_ptr< AsyncUDPSocket > socket_
constexpr detail::Map< Move > move
void onDataAvailable(const folly::SocketAddress &clientAddress, size_t len, bool truncated) noexceptoverride
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
std::pair< void *, std::size_t > preallocate(std::size_t min, std::size_t newAllocationSize, std::size_t max=std::numeric_limits< std::size_t >::max())
folly::SocketAddress address() const
void onReadError(const AsyncSocketException &ex) noexceptoverride
void onReadClosed() noexceptoverride
virtual void onListenResumed() noexcept
constexpr auto data(C &c) -> decltype(c.data())
AsyncUDPServerSocket(EventBase *evb, size_t sz=1500)
virtual void onListenStopped() noexcept=0
NetworkSocket socket(int af, int type, int protocol)
void setReusePort(bool reusePort)
virtual void onListenStarted() noexcept=0
void bind(const folly::SocketAddress &addy)
std::vector< Listener > listeners_
void getReadBuffer(void **buf, size_t *len) noexceptoverride
EventBase * getEventBase() const override
void postallocate(std::size_t n)
ThreadPoolListHook * addr
virtual ~Callback()=default