/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2014-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#pragma once
-#include <folly/io/IOBuf.h>
+#include <memory>
+
#include <folly/ScopeGuard.h>
-#include <folly/io/async/AsyncSocketException.h>
+#include <folly/SocketAddress.h>
+#include <folly/io/IOBuf.h>
#include <folly/io/async/AsyncSocketBase.h>
-#include <folly/io/async/EventHandler.h>
+#include <folly/io/async/AsyncSocketException.h>
#include <folly/io/async/EventBase.h>
-#include <folly/SocketAddress.h>
-
-#include <memory>
+#include <folly/io/async/EventHandler.h>
namespace folly {
* given eventbase
*/
explicit AsyncUDPSocket(EventBase* evb);
- ~AsyncUDPSocket();
+ ~AsyncUDPSocket() override;
/**
* Returns the address server is listening on
reuseAddr_ = reuseAddr;
}
+ EventBase* getEventBase() const {
+ return eventBase_;
+ }
+
+ protected:
+ virtual ssize_t sendmsg(int socket, const struct msghdr* message, int flags) {
+ return ::sendmsg(socket, message, flags);
+ }
+
+ // Non-null only when we are reading
+ ReadCallback* readCallback_;
+
private:
AsyncUDPSocket(const AsyncUDPSocket&) = delete;
AsyncUDPSocket& operator=(const AsyncUDPSocket&) = delete;
// EventHandler
- void handlerReady(uint16_t events) noexcept;
+ void handlerReady(uint16_t events) noexcept override;
void handleRead() noexcept;
bool updateRegistration() noexcept;
// Temp space to receive client address
folly::SocketAddress clientAddress_;
- // Non-null only when we are reading
- ReadCallback* readCallback_;
-
bool reuseAddr_{true};
bool reusePort_{false};
};
-} // Namespace
+} // namespace folly