#include "net/socket/socket_posix.h"
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/task/current_thread.h"
#include "build/build_config.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/sockaddr_storage.h"
#include "net/base/trace_constants.h"
#include "net/base/tracing.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#if BUILDFLAG(IS_FUCHSIA)
#include <poll.h>
#include <sys/ioctl.h>
#endif
namespace net {
namespace {
int MapAcceptError(int os_error) { … }
int MapConnectError(int os_error) { … }
}
SocketPosix::SocketPosix()
: … { … }
SocketPosix::~SocketPosix() { … }
int SocketPosix::Open(int address_family) { … }
int SocketPosix::AdoptConnectedSocket(SocketDescriptor socket,
const SockaddrStorage& address) { … }
int SocketPosix::AdoptUnconnectedSocket(SocketDescriptor socket) { … }
SocketDescriptor SocketPosix::ReleaseConnectedSocket() { … }
int SocketPosix::Bind(const SockaddrStorage& address) { … }
int SocketPosix::Listen(int backlog) { … }
int SocketPosix::Accept(std::unique_ptr<SocketPosix>* socket,
CompletionOnceCallback callback) { … }
int SocketPosix::Connect(const SockaddrStorage& address,
CompletionOnceCallback callback) { … }
bool SocketPosix::IsConnected() const { … }
bool SocketPosix::IsConnectedAndIdle() const { … }
int SocketPosix::Read(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int SocketPosix::ReadIfReady(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int SocketPosix::CancelReadIfReady() { … }
int SocketPosix::Write(
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
const NetworkTrafficAnnotationTag& ) { … }
int SocketPosix::WaitForWrite(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int SocketPosix::GetLocalAddress(SockaddrStorage* address) const { … }
int SocketPosix::GetPeerAddress(SockaddrStorage* address) const { … }
void SocketPosix::SetPeerAddress(const SockaddrStorage& address) { … }
bool SocketPosix::HasPeerAddress() const { … }
void SocketPosix::Close() { … }
void SocketPosix::DetachFromThread() { … }
void SocketPosix::OnFileCanReadWithoutBlocking(int fd) { … }
void SocketPosix::OnFileCanWriteWithoutBlocking(int fd) { … }
int SocketPosix::DoAccept(std::unique_ptr<SocketPosix>* socket) { … }
void SocketPosix::AcceptCompleted() { … }
int SocketPosix::DoConnect() { … }
void SocketPosix::ConnectCompleted() { … }
int SocketPosix::DoRead(IOBuffer* buf, int buf_len) { … }
void SocketPosix::RetryRead(int rv) { … }
void SocketPosix::ReadCompleted() { … }
int SocketPosix::DoWrite(IOBuffer* buf, int buf_len) { … }
void SocketPosix::WriteCompleted() { … }
void SocketPosix::StopWatchingAndCleanUp(bool close_socket) { … }
}