本文整理汇总了C#中System.Net.Sockets.SafeCloseSocket类的典型用法代码示例。如果您正苦于以下问题:C# SafeCloseSocket类的具体用法?C# SafeCloseSocket怎么用?C# SafeCloseSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeCloseSocket类属于System.Net.Sockets命名空间,在下文中一共展示了SafeCloseSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Accept
internal static SafeCloseSocket Accept(
SafeCloseSocket socketHandle,
byte[] socketAddress,
ref int socketAddressSize)
{
return CreateSocket(InnerSafeCloseSocket.Accept(socketHandle, socketAddress, ref socketAddressSize));
}
示例2: 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);
}
示例3: 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);
}
示例4: DoOperationAccept
internal unsafe SocketError DoOperationAccept(Socket socket, SafeCloseSocket handle, SafeCloseSocket acceptHandle, out int bytesTransferred)
{
Debug.Assert(acceptHandle == null);
bytesTransferred = 0;
return handle.AsyncContext.AcceptAsync(_buffer ?? _acceptBuffer, _acceptAddressBufferCount / 2, AcceptCompletionCallback);
}
示例5: SafeNativeOverlapped
public unsafe SafeNativeOverlapped(SafeCloseSocket socketHandle, NativeOverlapped* handle)
: this((IntPtr)handle)
{
_safeCloseSocket = socketHandle;
GlobalLog.Print("SafeNativeOverlapped#" + Logging.HashString(this) + "::ctor(socket#" + Logging.HashString(socketHandle) + ")");
#if DEBUG
_safeCloseSocket.AddRef();
#endif
}
示例6: 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;
}
示例7: SafeNativeOverlapped
public unsafe SafeNativeOverlapped(SafeCloseSocket socketHandle, NativeOverlapped* handle)
: this((IntPtr)handle)
{
SocketHandle = socketHandle;
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"socketHandle:{socketHandle}");
#if DEBUG
SocketHandle.AddRef();
#endif
}
示例8: DoOperationAccept
internal unsafe SocketError DoOperationAccept(Socket socket, SafeCloseSocket handle, SafeCloseSocket acceptHandle, out int bytesTransferred)
{
if (_buffer != null)
{
throw new PlatformNotSupportedException(SR.net_sockets_accept_receive_notsupported);
}
Debug.Assert(acceptHandle == null, $"Unexpected acceptHandle: {acceptHandle}");
bytesTransferred = 0;
return handle.AsyncContext.AcceptAsync(_acceptBuffer, _acceptAddressBufferCount / 2, AcceptCompletionCallback);
}
示例9: 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);
}
示例10: SafeNativeOverlapped
public unsafe SafeNativeOverlapped(SafeCloseSocket socketHandle, NativeOverlapped* handle)
: this((IntPtr)handle)
{
SocketHandle = socketHandle;
if (GlobalLog.IsEnabled)
{
GlobalLog.Print("SafeNativeOverlapped#" + LoggingHash.HashString(this) + "::ctor(socket#" + LoggingHash.HashString(socketHandle) + ")");
}
#if DEBUG
SocketHandle.AddRef();
#endif
}
示例11: 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);
}
示例12: Receive
private static unsafe int Receive(SafeCloseSocket socket, SocketFlags flags, byte[] buffer, int offset, int count, byte[] socketAddress, ref int socketAddressLen, out SocketFlags receivedFlags, out Interop.Error errno)
{
Debug.Assert(socketAddress != null || socketAddressLen == 0, $"Unexpected values: socketAddress={socketAddress}, socketAddressLen={socketAddressLen}");
long received;
int sockAddrLen = 0;
if (socketAddress != null)
{
sockAddrLen = socketAddressLen;
}
fixed (byte* sockAddr = socketAddress)
fixed (byte* b = buffer)
{
var iov = new Interop.Sys.IOVector {
Base = (b == null) ? null : &b[offset],
Count = (UIntPtr)count
};
var messageHeader = new Interop.Sys.MessageHeader {
SocketAddress = sockAddr,
SocketAddressLen = sockAddrLen,
IOVectors = &iov,
IOVectorCount = 1
};
errno = Interop.Sys.ReceiveMessage(socket, &messageHeader, flags, &received);
receivedFlags = messageHeader.Flags;
sockAddrLen = messageHeader.SocketAddressLen;
}
if (errno != Interop.Error.SUCCESS)
{
return -1;
}
socketAddressLen = sockAddrLen;
return checked((int)received);
}
示例13: SetIPv6MulticastOption
public static unsafe SocketError SetIPv6MulticastOption(SafeCloseSocket handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
{
Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership);
Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
Interop.Sys.MulticastOption.MULTICAST_ADD :
Interop.Sys.MulticastOption.MULTICAST_DROP;
var opt = new Interop.Sys.IPv6MulticastOption {
Address = optionValue.Group.GetNativeIPAddress(),
InterfaceIndex = (int)optionValue.InterfaceIndex
};
Interop.Error err = Interop.Sys.SetIPv6MulticastOption(handle.FileDescriptor, optName, &opt);
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}
示例14: SetLingerOption
public static unsafe SocketError SetLingerOption(SafeCloseSocket handle, LingerOption optionValue)
{
var opt = new Interop.Sys.LingerOption {
OnOff = optionValue.Enabled ? 1 : 0,
Seconds = optionValue.LingerTime
};
Interop.Error err = Interop.Sys.SetLingerOption(handle.FileDescriptor, &opt);
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}
示例15: SetSockOpt
public static unsafe SocketError SetSockOpt(SafeCloseSocket handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
{
Interop.Error err;
if (optionLevel == SocketOptionLevel.Socket)
{
if (optionName == SocketOptionName.ReceiveTimeout)
{
handle.ReceiveTimeout = optionValue == 0 ? -1 : optionValue;
err = Interop.Sys.SetReceiveTimeout(handle.FileDescriptor, optionValue);
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}
else if (optionName == SocketOptionName.SendTimeout)
{
handle.SendTimeout = optionValue == 0 ? -1 : optionValue;
err = Interop.Sys.SetSendTimeout(handle.FileDescriptor, optionValue);
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}
}
err = Interop.Sys.SetSockOpt(handle.FileDescriptor, optionLevel, optionName, (byte*)&optionValue, sizeof(int));
return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
}