本文整理汇总了C#中SafeCloseSocket类的典型用法代码示例。如果您正苦于以下问题:C# SafeCloseSocket类的具体用法?C# SafeCloseSocket怎么用?C# SafeCloseSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeCloseSocket类属于命名空间,在下文中一共展示了SafeCloseSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisconnectExBlocking
internal bool DisconnectExBlocking(SafeCloseSocket socketHandle, IntPtr overlapped, int flags, int reserved)
{
EnsureDynamicWinsockMethods();
DisconnectExDelegateBlocking disconnectEx_Blocking = _dynamicWinsockMethods.GetDelegate<DisconnectExDelegateBlocking>(socketHandle);
return disconnectEx_Blocking(socketHandle, overlapped, flags, reserved);
}
示例2: DisconnectEx
internal bool DisconnectEx(SafeCloseSocket socketHandle, SafeHandle overlapped, int flags, int reserved)
{
EnsureDynamicWinsockMethods();
DisconnectExDelegate disconnectEx = _dynamicWinsockMethods.GetDelegate<DisconnectExDelegate>(socketHandle);
return disconnectEx(socketHandle, overlapped, flags, reserved);
}
示例3: GetAvailable
public static SocketError GetAvailable(SafeCloseSocket handle, out int available)
{
int value = 0;
SocketError errorCode = Interop.Winsock.ioctlsocket(
handle,
Interop.Winsock.IoctlSocketConstants.FIONREAD,
ref value);
available = value;
return errorCode == SocketError.SocketError ? GetLastSocketError() : SocketError.Success;
}
示例4: GetOrCreateAcceptSocket
private Socket GetOrCreateAcceptSocket(Socket acceptSocket, bool unused, string propertyName, out SafeCloseSocket handle)
{
// AcceptSocket is not supported on Unix.
if (acceptSocket != null)
{
throw new PlatformNotSupportedException();
}
handle = null;
return null;
}
示例5: ConnectEx
internal bool ConnectEx(SafeCloseSocket socketHandle,
IntPtr socketAddress,
int socketAddressSize,
IntPtr buffer,
int dataLength,
out int bytesSent,
SafeHandle overlapped)
{
EnsureDynamicWinsockMethods();
ConnectExDelegate connectEx = _dynamicWinsockMethods.GetDelegate<ConnectExDelegate>(socketHandle);
return connectEx(socketHandle, socketAddress, socketAddressSize, buffer, dataLength, out bytesSent, overlapped);
}
示例6: SetBlocking
public static SocketError SetBlocking(SafeCloseSocket handle, bool shouldBlock, out bool willBlock)
{
int intBlocking = shouldBlock ? 0 : -1;
SocketError errorCode;
errorCode = Interop.Winsock.ioctlsocket(
handle,
Interop.Winsock.IoctlSocketConstants.FIONBIO,
ref intBlocking);
if (errorCode == SocketError.SocketError)
{
errorCode = (SocketError)Marshal.GetLastWin32Error();
}
willBlock = intBlocking == 0;
return errorCode;
}
示例7: AcceptEx
internal bool AcceptEx(SafeCloseSocket listenSocketHandle,
SafeCloseSocket acceptSocketHandle,
IntPtr buffer,
int len,
int localAddressLength,
int remoteAddressLength,
out int bytesReceived,
SafeHandle overlapped)
{
EnsureDynamicWinsockMethods();
AcceptExDelegate acceptEx = _dynamicWinsockMethods.GetDelegate<AcceptExDelegate>(listenSocketHandle);
return acceptEx(listenSocketHandle,
acceptSocketHandle,
buffer,
len,
localAddressLength,
remoteAddressLength,
out bytesReceived,
overlapped);
}
示例8: Socket
private Socket(SafeCloseSocket fd)
{
this.willBlock = true;
this.willBlockInternal = true;
this.m_CloseTimeout = -1;
s_LoggingEnabled = Logging.On;
if (s_LoggingEnabled)
{
Logging.Enter(Logging.Sockets, this, "Socket", (string) null);
}
InitializeSockets();
if ((fd == null) || fd.IsInvalid)
{
throw new ArgumentException(SR.GetString("net_InvalidSocketHandle"));
}
this.m_Handle = fd;
this.addressFamily = System.Net.Sockets.AddressFamily.Unknown;
this.socketType = System.Net.Sockets.SocketType.Unknown;
this.protocolType = System.Net.Sockets.ProtocolType.Unknown;
if (s_LoggingEnabled)
{
Logging.Exit(Logging.Sockets, this, "Socket", (string) null);
}
}
示例9: CreateSocket
protected static void CreateSocket(InnerSafeCloseSocket socket, SafeCloseSocket target)
{
if ((socket != null) && socket.IsInvalid)
{
target.SetHandleAsInvalid();
}
else
{
bool success = false;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
socket.DangerousAddRef(ref success);
}
catch
{
if (success)
{
socket.DangerousRelease();
success = false;
}
}
finally
{
if (success)
{
target.SetInnerSocket(socket);
socket.Close();
}
else
{
target.SetHandleAsInvalid();
}
}
}
}
示例10: TransmitPackets
internal bool TransmitPackets(SafeCloseSocket socketHandle, IntPtr packetArray, int elementCount, int sendSize, SafeNativeOverlapped overlapped)
{
EnsureDynamicWinsockMethods();
TransmitPacketsDelegate transmitPackets = _dynamicWinsockMethods.GetDelegate<TransmitPacketsDelegate>(socketHandle);
// UseDefaultWorkerThread = 0.
return transmitPackets(socketHandle, packetArray, elementCount, sendSize, overlapped, 0);
}
示例11: DoOperationSendTo
internal SocketError DoOperationSendTo(SafeCloseSocket handle, out int bytesTransferred)
{
PrepareIOCPOperation();
SocketError socketError;
if (_buffer != null)
{
// Single buffer case.
socketError = Interop.Winsock.WSASendTo(
handle,
ref _wsaBuffer,
1,
out bytesTransferred,
_socketFlags,
_ptrSocketAddressBuffer,
_socketAddress.Size,
_ptrNativeOverlapped,
IntPtr.Zero);
}
else
{
socketError = Interop.Winsock.WSASendTo(
handle,
_wsaBufferArray,
_wsaBufferArray.Length,
out bytesTransferred,
_socketFlags,
_ptrSocketAddressBuffer,
_socketAddress.Size,
_ptrNativeOverlapped,
IntPtr.Zero);
}
if (socketError == SocketError.SocketError)
{
socketError = SocketPal.GetLastSocketError();
}
return socketError;
}
示例12: DoOperationSendPackets
internal SocketError DoOperationSendPackets(Socket socket, SafeCloseSocket handle)
{
PrepareIOCPOperation();
bool result = socket.TransmitPackets(
handle,
_ptrSendPacketsDescriptor,
_sendPacketsDescriptor.Length,
_sendPacketsSendSize,
_ptrNativeOverlapped);
return result ? SocketError.Success : SocketPal.GetLastSocketError();
}
示例13: DoOperationReceiveMessageFrom
internal unsafe SocketError DoOperationReceiveMessageFrom(Socket socket, SafeCloseSocket handle, out int bytesTransferred)
{
PrepareIOCPOperation();
SocketError socketError = socket.WSARecvMsg(
handle,
_ptrWSAMessageBuffer,
out bytesTransferred,
_ptrNativeOverlapped,
IntPtr.Zero);
if (socketError == SocketError.SocketError)
{
socketError = SocketPal.GetLastSocketError();
}
return socketError;
}
示例14: DoOperationReceiveFrom
internal unsafe SocketError DoOperationReceiveFrom(SafeCloseSocket handle, out SocketFlags flags, out int bytesTransferred)
{
PrepareIOCPOperation();
flags = _socketFlags;
SocketError socketError;
if (_buffer != null)
{
socketError = Interop.Winsock.WSARecvFrom(
handle,
ref _wsaBuffer,
1,
out bytesTransferred,
ref flags,
_ptrSocketAddressBuffer,
_ptrSocketAddressBufferSize,
_ptrNativeOverlapped,
IntPtr.Zero);
}
else
{
socketError = Interop.Winsock.WSARecvFrom(
handle,
_wsaBufferArray,
_wsaBufferArray.Length,
out bytesTransferred,
ref flags,
_ptrSocketAddressBuffer,
_ptrSocketAddressBufferSize,
_ptrNativeOverlapped,
IntPtr.Zero);
}
if (socketError == SocketError.SocketError)
{
socketError = SocketPal.GetLastSocketError();
}
return socketError;
}
示例15: DoOperationConnect
internal unsafe SocketError DoOperationConnect(Socket socket, SafeCloseSocket handle, out int bytesTransferred)
{
PrepareIOCPOperation();
SocketError socketError = SocketError.Success;
if (!socket.ConnectEx(
handle,
_ptrSocketAddressBuffer,
_socketAddress.Size,
_ptrSingleBuffer,
Count,
out bytesTransferred,
_ptrNativeOverlapped))
{
socketError = SocketPal.GetLastSocketError();
}
return socketError;
}