+void AsyncServerSocket::bindSocket(
+ int fd,
+ const SocketAddress& address,
+ bool isExistingSocket) {
+ sockaddr_storage addrStorage;
+ address.getAddress(&addrStorage);
+ sockaddr* saddr = reinterpret_cast<sockaddr*>(&addrStorage);
+
+ if (fsp::bind(fd, saddr, address.getActualSize()) != 0) {
+ if (!isExistingSocket) {
+ closeNoInt(fd);
+ }
+ folly::throwSystemError(errno,
+ "failed to bind to async server socket: " +
+ address.describe());
+ }
+
+#if __linux__
+ if (noTransparentTls_) {
+ // Ignore return value, errors are ok
+ setsockopt(fd, SOL_SOCKET, SO_NO_TRANSPARENT_TLS, nullptr, 0);
+ }
+#endif
+
+ // If we just created this socket, update the EventHandler and set socket_
+ if (!isExistingSocket) {
+ sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
+ }
+}
+
+bool AsyncServerSocket::setZeroCopy(bool enable) {
+ if (msgErrQueueSupported) {
+ int fd = getSocket();
+ int val = enable ? 1 : 0;
+ int ret = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &val, sizeof(val));
+
+ return (0 == ret);
+ }
+
+ return false;
+}
+