System::Net::Sockets::Socket 类

Socket class

Socket 类实现了 Berkeley 套接字接口。

class Socket : public System::IDisposable

方法

方法描述
Accept()为新创建的连接创建一个新的套接字。
BeginConnect(System::SharedPtr<EndPoint>, AsyncCallback, System::SharedPtr<Object>)发起异步连接操作。
BeginConnect(String, int32_t, AsyncCallback, System::SharedPtr<Object>)发起异步连接操作。
BeginConnect(System::SharedPtr<IPAddress>, int32_t, AsyncCallback, System::SharedPtr<Object>)发起异步连接操作。
BeginConnect(System::ArrayPtr<System::SharedPtr<IPAddress>>, int32_t, AsyncCallback, System::SharedPtr<Object>)发起异步连接操作。
BeginReceive(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, AsyncCallback, System::SharedPtr<Object>)发起异步写入操作。
BeginSend(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, AsyncCallback, System::SharedPtr<Object>)发起异步发送操作。
Bind(System::SharedPtr<EndPoint>)将套接字绑定到指定的本地端点。
Close()关闭套接字连接。
Close(int)在指定的超时时间内关闭套接字连接,以允许发送排队的数据。
Connect(System::SharedPtr<EndPoint>)建立到指定远程端点的连接。
Connect(System::SharedPtr<IPAddress>, int32_t)建立到指定远程端点的连接。
Connect(String, int32_t)建立到指定远程端点的连接。
Connect(System::ArrayPtr<System::SharedPtr<IPAddress>>, int32_t)建立到指定远程端点的连接。
Dispose() override不执行任何操作。
EndConnect(System::SharedPtr<IAsyncResult>)等待指定的异步连接操作完成。
EndReceive(System::SharedPtr<IAsyncResult>)等待指定的异步接收操作完成。
EndReceive(System::SharedPtr<IAsyncResult>, SocketError&)等待指定的异步接收操作完成。
EndSend(System::SharedPtr<IAsyncResult>)等待指定的异步发送操作完成。
EndSend(System::SharedPtr<IAsyncResult>, SocketError&)等待指定的异步发送操作完成。
get_AddressFamily()返回地址族。
get_Available()获取从网络接收的字节数以及可供读取的字节数。
get_Blocking()获取指示套接字是否处于阻塞模式的值。
get_Connected()返回指示套接字是否已连接到远程主机的值。
get_DontFragment()获取指示套接字是否允许 IP 数据报分片的值。
get_DualMode()获取指示套接字是否处于双模式的值。
get_EnableBroadcast()获取指示套接字是否允许广播数据包的值。
get_ExclusiveAddressUse()获取指示是否只能有一个进程将套接字绑定到端口的值。
get_IsBound()返回指示套接字是否绑定到特定本地端口的值。
get_LingerState()获取指示套接字是否会延迟关闭以尝试发送所有挂起数据的值。
get_LocalEndPoint()返回本地端点。
get_MulticastLoopback()获取指示套接字是否接收外发多播数据包的值。
get_NoDelay()获取一个指示套接字是否使用 Nagle 算法的值。
static get_OSSupportsIPv4()返回一个指示操作系统和网络适配器是否支持 IPv4 的值。
static get_OSSupportsIPv6()返回一个指示操作系统和网络适配器是否支持 IPv6 的值。
get_ProtocolType()返回协议类型。
get_ReceiveBufferSize()获取接收缓冲区大小。
get_ReceiveTimeout()获取一个时间段,在此之后 ‘Receive’ 调用将超时。
get_RemoteEndPoint()返回远程端点。
get_SendBufferSize()获取发送缓冲区大小。
get_SendTimeout()获取一个时间段,在此之后 ‘Send’ 调用将超时。
get_SocketType()返回套接字类型。
static get_SupportsIPv4()RTTI 信息。
get_Ttl()获取 TTL 值。
GetImpl() const返回指向实现的指针。
GetSocketOption(SocketOptionLevel, SocketOptionName)返回与指定选项名称对应的值。
GetSocketOption(SocketOptionLevel, SocketOptionName, System::ArrayPtr<uint8_t>)获取与指定选项名称对应的值。
GetSocketOption(SocketOptionLevel, SocketOptionName, int32_t)返回与指定选项名称对应的值。
IOControl(int32_t, System::ArrayPtr<uint8_t>, System::ArrayPtr<uint8_t>)设置套接字的低级操作模式。
IOControl(IOControlCode, System::ArrayPtr<uint8_t>, System::ArrayPtr<uint8_t>)设置套接字的低级操作模式。
Listen(int32_t)将套接字状态更改为 ’listen’。
Poll(int32_t, SelectMode)根据指定的轮询模式返回套接字的状态。
Receive(System::ArrayPtr<uint8_t>, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::ArrayView<uint8_t>, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::StackArray<uint8_t, N>&, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::ArrayPtr<uint8_t>, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::ArrayView<uint8_t>, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::StackArray<uint8_t, N>&, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::ArrayPtr<uint8_t>)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::ArrayView<uint8_t>)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::StackArray<uint8_t, N>&)从套接字接收数据并写入指定的字节数组。
Receive(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags)从套接字接收数据并写入指定的字节数组。
Receive(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, SocketError&)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags, SocketError&)从套接字接收数据并写入指定的字节数组。
Receive(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags, SocketError&)从套接字接收数据并写入指定的字节数组。
Receive(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>)从套接字接收数据并写入指定的字节数组集合。
Receive(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>, SocketFlags)从套接字接收数据并写入指定的字节数组集合。
Receive(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>, SocketFlags, SocketError&)从套接字接收数据并写入指定的字节数组集合。
ReceiveFrom(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::ArrayPtr<uint8_t>, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::ArrayView<uint8_t>, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::StackArray<uint8_t, N>&, int32_t, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::ArrayPtr<uint8_t>, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::ArrayView<uint8_t>, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::ArrayPtr<uint8_t>, SocketFlags, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::ArrayPtr<uint8_t>, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::ArrayView<uint8_t>, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveFrom(System::Details::StackArray<uint8_t, N>&, System::SharedPtr<EndPoint>&)从指定的端点接收数据并写入指定的字节数组。
ReceiveMessageFrom(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags&, System::SharedPtr<EndPoint>&, IPPacketInformation&)从指定的端点接收数据并写入指定的字节数组。
ReceiveMessageFrom(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags&, System::SharedPtr<EndPoint>&, IPPacketInformation&)从指定的端点接收数据并写入指定的字节数组。
ReceiveMessageFrom(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags&, System::SharedPtr<EndPoint>&, IPPacketInformation&)从指定的端点接收数据并写入指定的字节数组。
Send(System::ArrayPtr<uint8_t>, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::ArrayView<uint8_t>, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::StackArray<uint8_t, N>&, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::ArrayPtr<uint8_t>, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::ArrayView<uint8_t>, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::StackArray<uint8_t, N>&, SocketFlags)将指定的数据发送到套接字。
Send(System::ArrayPtr<uint8_t>)将指定的数据发送到套接字。
Send(System::Details::ArrayView<uint8_t>)将指定的数据发送到套接字。
Send(System::Details::StackArray<uint8_t, N>&)将指定的数据发送到套接字。
Send(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>)将指定的数据发送到套接字。
Send(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>, SocketFlags)将指定的数据发送到套接字。
Send(System::SharedPtr<Collections::Generic::IList<ArraySegment<uint8_t>>>, SocketFlags, SocketError&)将指定的数据发送到套接字。
Send(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags)将指定的数据发送到套接字。
Send(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, SocketError&)将指定的数据发送到套接字。
Send(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags, SocketError&)将指定的数据发送到套接字。
Send(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags, SocketError&)将指定的数据发送到套接字。
SendTo(System::ArrayPtr<uint8_t>, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::ArrayView<uint8_t>, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::StackArray<uint8_t, N>&, int32_t, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::ArrayPtr<uint8_t>, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::ArrayView<uint8_t>, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::StackArray<uint8_t, N>&, int32_t, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::ArrayPtr<uint8_t>, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::ArrayView<uint8_t>, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::StackArray<uint8_t, N>&, SocketFlags, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::ArrayPtr<uint8_t>, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::ArrayView<uint8_t>, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
SendTo(System::Details::StackArray<uint8_t, N>&, System::SharedPtr<EndPoint>)将指定的数据发送到指定的端点。
set_Blocking(bool)设置一个指示套接字是否处于阻塞模式的值。
set_ConnectionTimeout(int32_t)设置连接超时。
set_DontFragment(bool)设置一个指示套接字是否允许 IP 数据报被分片的值。
set_DualMode(bool)设置一个值,指示套接字是否处于双模式。
set_EnableBroadcast(bool)设置一个值,指示套接字是否允许广播数据包。
set_ExclusiveAddressUse(bool)设置一个值,指示是否只能有一个进程将套接字绑定到端口。
set_LingerState(System::SharedPtr<LingerOption>)设置一个值,指示套接字是否会延迟关闭以尝试发送所有未完成的数据。
set_MulticastLoopback(bool)设置一个值,指示套接字是否接收外发的多播数据包。
set_NoDelay(bool)设置一个值,指示套接字是否使用 Nagle 算法。
set_ReceiveBufferSize(int32_t)设置接收缓冲区大小。
set_ReceiveTimeout(int32_t)设置一个时间段,在此之后 ‘Receive’ 调用将超时。
set_SendBufferSize(int32_t)设置发送缓冲区大小。
set_SendTimeout(int32_t)设置一个时间段,在此之后 ‘Send’ 调用将超时。
set_Ttl(int16_t)设置 TTL 值。
SetSocketOption(SocketOptionLevel, SocketOptionName, int32_t)将指定的套接字选项设置为指定的值。
SetSocketOption(SocketOptionLevel, SocketOptionName, System::ArrayPtr<uint8_t>)将指定的套接字选项设置为指定的值。
SetSocketOption(SocketOptionLevel, SocketOptionName, bool)将指定的套接字选项设置为指定的值。
SetSocketOption(SocketOptionLevel, SocketOptionName, System::SharedPtr<Object>)将指定的套接字选项设置为指定的值。
Shutdown(SocketShutdown)禁用套接字的发送和接收操作。
Socket(System::Net::Sockets::SocketType, System::Net::Sockets::ProtocolType)构造一个新实例。
Socket(System::Net::Sockets::AddressFamily, System::Net::Sockets::SocketType, System::Net::Sockets::ProtocolType)构造一个新实例。
virtual ~Socket()销毁当前实例。

Typedefs

类型定义描述
ImplPtr套接字实现。

另见