NetworkSocket is just a very thin wrapper around either a file descriptor or a SOCKET depending on platform, along with a couple of helper methods for explicitly converting to/from file descriptors, even on Windows.

Synopsis

Declared in <folly/net/NetworkSocket.h>

struct NetworkSocket;

Type Aliases

Name

Description

native_handle_type

The platform‐specific native socket handle type.

Member Functions

Name

Description

NetworkSocket [constructor]

Constructors

toFd

Return the file descriptor associated with this NetworkSocket.

Static Member Functions

Name

Description

fromFd

fromFd overloads

Data Members

Name

Description

data

The underlying native socket handle.

Static Data Members

Name

Description

invalid_handle_value

The sentinel value representing an invalid socket handle.

Friends

Name

Description

folly::operator!=

Compares two NetworkSockets for inequality.

folly::operator==

Compares two NetworkSockets for equality.

Non-Member Functions

Name

Description

applySocketOptions

Applies the given socket options to a socket at the given position.

closeNoInt

Closes a network socket, retrying on EINTR.

shutdownNoInt

Shuts down a socket, retrying on EINTR.

netops::accept

Accepts a connection on a listening socket.

netops::bind

Binds a socket to a local address.

netops::close

Closes a socket.

netops::connect

Connects a socket to a remote address.

netops::getpeername

Retrieves the address of the connected peer.

netops::getsockname

Retrieves the local address bound to a socket.

netops::getsockopt

Retrieves a socket option.

netops::listen

Marks a socket as accepting connections.

netops::recv

Receives data from a connected socket.

netops::recvfrom

Receives data and records the source address.

netops::recvmmsg

Receives multiple messages in a single call.

netops::recvmsg

Receives a message, including ancillary data.

netops::send

Sends data on a connected socket.

netops::sendmmsg

Sends multiple messages in a single call.

netops::sendmsg

Sends a message, including ancillary data.

netops::sendto

Sends data to a specific destination address.

netops::set_socket_blocking

Puts a socket into blocking mode.

netops::set_socket_close_on_exec

Sets the close‐on‐exec flag on a socket.

netops::set_socket_non_blocking

Puts a socket into non‐blocking mode.

netops::setsockopt

Sets a socket option.

netops::shutdown

Shuts down part or all of a full‐duplex connection.

netops::socket

Creates a socket.

Created with MrDocs