本文整理汇总了C#中System.Net.Sockets.SafeCloseSocket.DangerousRelease方法的典型用法代码示例。如果您正苦于以下问题:C# SafeCloseSocket.DangerousRelease方法的具体用法?C# SafeCloseSocket.DangerousRelease怎么用?C# SafeCloseSocket.DangerousRelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Sockets.SafeCloseSocket
的用法示例。
在下文中一共展示了SafeCloseSocket.DangerousRelease方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Poll
public static unsafe SocketError Poll(SafeCloseSocket handle, int microseconds, SelectMode mode, out bool status)
{
uint* fdSet = stackalloc uint[Interop.Sys.FD_SETSIZE_UINTS];
Interop.Sys.FD_ZERO(fdSet);
bool releaseHandle = false;
try
{
handle.DangerousAddRef(ref releaseHandle);
int fd = (int)handle.DangerousGetHandle();
Interop.Sys.FD_SET(fd, fdSet);
int fdCount = 0;
uint* readFds = null;
uint* writeFds = null;
uint* errorFds = null;
switch (mode)
{
case SelectMode.SelectRead:
readFds = fdSet;
fdCount = fd + 1;
break;
case SelectMode.SelectWrite:
writeFds = fdSet;
fdCount = fd + 1;
break;
case SelectMode.SelectError:
errorFds = fdSet;
fdCount = fd + 1;
break;
}
int socketCount = 0;
Interop.Error err = Interop.Sys.Select(fdCount, readFds, writeFds, errorFds, microseconds, &socketCount);
if (err != Interop.Error.SUCCESS)
{
status = false;
return GetSocketErrorForErrorCode(err);
}
status = Interop.Sys.FD_ISSET(fd, fdSet);
}
finally
{
if (releaseHandle)
{
handle.DangerousRelease();
}
}
return SocketError.Success;
}