1 /*
2  * Copyright (c) Facebook, Inc. and its affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  *
7  */
8 
9 #pragma once
10 
11 #include <quic/server/QuicUDPSocketFactory.h>
12 
13 namespace quic {
14 
15 class QuicSharedUDPSocketFactory : public QuicUDPSocketFactory {
16  public:
~QuicSharedUDPSocketFactory()17   ~QuicSharedUDPSocketFactory() override {}
QuicSharedUDPSocketFactory()18   QuicSharedUDPSocketFactory() {}
19 
make(folly::EventBase * evb,int fd)20   std::unique_ptr<folly::AsyncUDPSocket> make(folly::EventBase* evb, int fd)
21       override {
22     auto sock = std::make_unique<folly::AsyncUDPSocket>(evb);
23     if (fd != -1) {
24       sock->setFD(
25           folly::NetworkSocket::fromFd(fd),
26           folly::AsyncUDPSocket::FDOwnership::SHARED);
27       sock->setDFAndTurnOffPMTU();
28     }
29     return sock;
30   }
31 };
32 } // namespace quic
33