Sese Framework
x.y.z
A cross-platform framework
|
#include <Socket.h>
Public 类型 | |
enum class | Type { TCP = SOCK_STREAM , UDP = SOCK_DGRAM } |
套接字类型 更多... | |
enum class | Family { IPv4 = AF_INET , IPv6 = AF_INET6 } |
协议族 更多... | |
enum class | ShutdownMode { READ = SHUT_RD , WRITE = SHUT_WR , BOTH = SHUT_RDWR } |
断开模式 更多... | |
using | Ptr = std::shared_ptr<Socket> |
Public 类型 继承自 sese::io::Stream | |
typedef std::shared_ptr< Stream > | Ptr |
Public 类型 继承自 sese::io::InputStream | |
typedef std::shared_ptr< InputStream > | Ptr |
Public 类型 继承自 sese::io::OutputStream | |
typedef std::shared_ptr< OutputStream > | Ptr |
Public 类型 继承自 sese::io::PeekableStream | |
typedef std::shared_ptr< PeekableStream > | Ptr |
Public 成员函数 | |
Socket (Family family, Type type, int32_t protocol=IPPROTO_IP) noexcept | |
Socket (socket_t handle, Address::Ptr address) noexcept | |
~Socket () noexcept override | |
virtual int32_t | bind (Address::Ptr address) noexcept |
virtual int32_t | connect (Address::Ptr address) noexcept |
virtual int32_t | listen (int32_t backlog) const noexcept |
virtual Socket::Ptr | accept () const |
virtual int32_t | shutdown (ShutdownMode mode) const |
bool | setNonblocking () const noexcept |
int64_t | read (void *buffer, size_t length) override |
int64_t | write (const void *buffer, size_t length) override |
int64_t | send (void *buffer, size_t length, const IPAddress::Ptr &to, int32_t flags) const |
int64_t | recv (void *buffer, size_t length, const IPAddress::Ptr &from, int32_t flags) const |
int64_t | peek (void *buffer, size_t length) override |
int64_t | trunc (size_t length) override |
int64_t | writeInt16 (int16_t value) |
int64_t | writeInt32 (int32_t value) |
int64_t | writeInt64 (int64_t value) |
int64_t | writeUint16 (uint16_t value) |
int64_t | writeUint32 (uint32_t value) |
int64_t | writeUint64 (uint64_t value) |
int64_t | readInt16 (int16_t &value) |
int64_t | readInt32 (int32_t &value) |
int64_t | readInt64 (int64_t &value) |
int64_t | readUint16 (uint16_t &value) |
int64_t | readUint32 (uint32_t &value) |
int64_t | readUint64 (uint64_t &value) |
void | close () override |
const socket_t & | getRawSocket () const |
const Address::Ptr & | getAddress () const |
Public 成员函数 继承自 sese::io::InputStream | |
virtual | ~InputStream () noexcept=default |
Public 成员函数 继承自 sese::io::OutputStream | |
virtual | ~OutputStream () noexcept=default |
int64_t | write (const std::string_view &buffer) |
int64_t | write (const text::StringView &buffer) |
template<typename T > | |
int64_t | write (std::vector< T > &buffer) |
template<typename T , size_t N> | |
int64_t | write (std::array< T, N > &buffer) |
Public 成员函数 继承自 sese::io::PeekableStream | |
virtual | ~PeekableStream ()=default |
Public 成员函数 继承自 sese::io::Closeable | |
virtual | ~Closeable ()=default |
静态 Public 成员函数 | |
static socket_t | socket (int family, int type, int protocol) noexcept |
static int | bind (socket_t socket, const sockaddr *addr, socklen_t addr_len) noexcept |
static socket_t | accept (socket_t socket, sockaddr *addr=nullptr, socklen_t *len=nullptr) noexcept |
static int | connect (socket_t socket, const sockaddr *addr, socklen_t addr_len) noexcept |
static int64_t | write (socket_t socket, const void *buffer, size_t len, int flags) noexcept |
static int64_t | read (socket_t socket, void *buffer, size_t len, int flags) noexcept |
static int | listen (socket_t socket, int backlog) noexcept |
static int | setNonblocking (socket_t socket) noexcept |
static void | close (socket_t socket) noexcept |
static int | shutdown (socket_t socket, ShutdownMode mode) noexcept |
Private 属性 | |
socket_t | handle {} |
Address::Ptr | address |
Native Socket 类
using sese::net::Socket::Ptr = std::shared_ptr<Socket> |
|
strong |
|
strong |
|
strong |
|
noexcept |
|
overridenoexcept |
|
nodiscardvirtual |
被 sese::security::SecuritySocket 重载.
引用了 accept(), address, sese::net::Address::create(), sese::net::Address::getRawAddress(), handle , 以及 MAKE_SHARED_PRIVATE.
被这些函数引用 accept().
|
staticnoexcept |
|
virtualnoexcept |
|
staticnoexcept |
|
overridevirtual |
实现了 sese::io::Closeable.
被这些函数引用 sese::security::SecuritySocket::accept(), sese::_windows::iocp::v1::NativeIOCPServer::acceptThreadProc(), close(), sese::_windows::iocp::v1::NativeIOCPServer::init(), sese::service::SystemBalanceLoader::init(), sese::_windows::iocp::v1::NativeIOCPServer::initConnectEx(), sese::iocp::v1::IOCPService::onAccept(), sese::service::TcpTransporter::onAccept(), sese::service::TcpTransporter::onClose(), sese::service::TcpTransporter::onRead(), sese::service::TcpTransporter::onTimeout(), sese::service::TcpTransporter::onWrite(), sese::_windows::iocp::v1::NativeIOCPServer::releaseContext(), sese::iocp::v1::IOCPService::releaseContext(), sese::_windows::iocp::v1::NativeIOCPServer::shutdown(), sese::service::SystemBalanceLoader::stop(), sese::service::UserBalanceLoader::stop(), sese::iocp::v1::IOCPService::~IOCPService(), sese::service::SystemBalanceLoader::~SystemBalanceLoader(), sese::service::TcpTransporter::~TcpTransporter() , 以及 sese::service::UserBalanceLoader::~UserBalanceLoader().
|
virtualnoexcept |
|
staticnoexcept |
|
inlinenodiscard |
|
inlinenodiscard |
|
virtualnoexcept |
|
staticnoexcept |
|
overridevirtual |
|
staticnoexcept |
|
overridevirtual |
TCP 接收字节
buffer | 缓存 |
length | 缓存大小 |
引用了 handle.
被这些函数引用 sese::iocp::v1::IOCPService::read() , 以及 sese::service::TcpTransporter::read().
|
inline |
引用了 FromBigEndian16() , 以及 R.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int64_t Socket::recv | ( | void * | buffer, |
size_t | length, | ||
const IPAddress::Ptr & | from, | ||
int32_t | flags ) const |
UDP 接收字节
buffer | 缓存 |
length | 缓存大小 |
from | 来源地址 |
flags | 标志 |
引用了 sese::net::Address::getRawAddress(), sese::net::Address::getRawAddressLength() , 以及 handle.
int64_t Socket::send | ( | void * | buffer, |
size_t | length, | ||
const IPAddress::Ptr & | to, | ||
int32_t | flags ) const |
UDP 发送字节
buffer | 缓存 |
length | 缓存大小 |
to | 目标地址 |
flags | 标志 |
引用了 sese::net::Address::getRawAddress(), sese::net::Address::getRawAddressLength() , 以及 handle.
|
noexcept |
引用了 handle.
被这些函数引用 sese::_windows::iocp::v1::NativeIOCPServer::acceptThreadProc(), sese::_windows::iocp::v1::NativeIOCPServer::init(), sese::service::SystemBalanceLoader::init(), sese::iocp::v1::IOCPService::onAccept(), sese::service::TcpTransporter::onAccept(), sese::_windows::iocp::v1::NativeIOCPServer::postConnect() , 以及 sese::iocp::v1::IOCPServer::postConnect().
|
staticnoexcept |
|
virtual |
被 sese::security::SecuritySocket 重载.
引用了 handle.
|
staticnoexcept |
|
staticnoexcept |
|
overridevirtual |
|
overridevirtual |
TCP 发送字节
buffer | 缓存 |
length | 缓存大小 |
引用了 handle.
被这些函数引用 sese::iocp::v1::IOCPService::write() , 以及 sese::service::TcpTransporter::write().
|
staticnoexcept |
|
inline |
引用了 ToBigEndian16() , 以及 W.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
被这些函数引用 accept().
|
private |
被这些函数引用 accept(), close(), peek(), read(), recv(), send(), setNonblocking(), shutdown(), trunc() , 以及 write().