// Copyright (C) 2021 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include"net/posix/posix_async_socket.h"
#include <errno.h> // for errno #include <fcntl.h> // for fcntl, FD_CLOEXEC, F_GETFL #include <string.h> // for strerror #include <sys/socket.h> // for getsockopt, send, MSG_NOSIGNAL #include <unistd.h> // for close, read
#include <functional> // for __base
#include"log.h" #include"model/setup/async_manager.h"// for AsyncManager
#ifdef _WIN32 #include"msvc-posix.h" #endif
/* set for very verbose debugging */ #ifdef NDEBUG #define DD(...) (void)0 #else #define DD(...) INFO(__VA_ARGS__) #endif
#ifdef SO_NOSIGPIPE // Disable SIGPIPE generation on Darwin. // When writing to a broken pipe, send() will return -1 and // set errno to EPIPE.
flags = 1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (constchar*)&flags, sizeof(flags)); #endif
}
ssize_t PosixAsyncSocket::Send(const uint8_t* buffer, uint64_t bufferSize) {
errno = 0;
ssize_t res = 0; #ifdef MSG_NOSIGNAL // Prevent SIGPIPE generation on Linux when writing to a broken pipe. // ::send() will return -1/EPIPE instead. constint sendFlags = MSG_NOSIGNAL; #else // For Darwin, this is handled by setting SO_NOSIGPIPE when creating // the socket. constint sendFlags = 0; #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.