SocketFastOpen.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2016-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <folly/portability/Sockets.h>
  18. #include <sys/types.h>
  19. #if !defined(FOLLY_ALLOW_TFO)
  20. #if defined(__linux__) || defined(__APPLE__)
  21. // only allow for linux right now
  22. #define FOLLY_ALLOW_TFO 1
  23. #endif
  24. #endif
  25. namespace folly {
  26. namespace detail {
  27. /**
  28. * tfo_sendto has the same semantics as sendmsg, but is used to
  29. * send with TFO data.
  30. */
  31. ssize_t tfo_sendmsg(int sockfd, const struct msghdr* msg, int flags);
  32. /**
  33. * Enable TFO on a listening socket.
  34. */
  35. int tfo_enable(int sockfd, size_t max_queue_size);
  36. /**
  37. * Check if TFO succeeded in being used.
  38. */
  39. bool tfo_succeeded(int sockfd);
  40. } // namespace detail
  41. } // namespace folly