• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SafeCloseSocket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SafeCloseSocket的典型用法代码示例。如果您正苦于以下问题:C# SafeCloseSocket类的具体用法?C# SafeCloseSocket怎么用?C# SafeCloseSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SafeCloseSocket类属于命名空间,在下文中一共展示了SafeCloseSocket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:Socket.Windows.cs


示例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);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:Socket.Windows.cs


示例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;
 }
开发者ID:chcosta,项目名称:corefx,代码行数:10,代码来源:SocketPal.Windows.cs


示例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;
        }
开发者ID:benpye,项目名称:corefx,代码行数:11,代码来源:Socket.Unix.cs


示例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);
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:13,代码来源:Socket.Windows.cs


示例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;
        }
开发者ID:vbouret,项目名称:corefx,代码行数:18,代码来源:SocketPal.Windows.cs


示例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);
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:21,代码来源:Socket.Windows.cs


示例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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:Socket.cs


示例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();
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:36,代码来源:SafeCloseSocket.cs


示例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);
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:Socket.Windows.cs


示例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;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:40,代码来源:SocketAsyncEventArgs.Windows.cs


示例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();
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:13,代码来源:SocketAsyncEventArgs.Windows.cs


示例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;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:18,代码来源:SocketAsyncEventArgs.Windows.cs


示例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;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:41,代码来源:SocketAsyncEventArgs.Windows.cs


示例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;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:20,代码来源:SocketAsyncEventArgs.Windows.cs


示例16: Disconnect

 public static SocketError Disconnect(Socket socket, SafeCloseSocket handle, bool reuseSocket)
 {
     throw new PlatformNotSupportedException();
 }
开发者ID:jemmy655,项目名称:corefx,代码行数:4,代码来源:SocketPal.Unix.cs


示例17: SetSockOpt

        public static unsafe SocketError SetSockOpt(SafeCloseSocket handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
        {
            if (optionLevel == SocketOptionLevel.Socket)
            {
                if (optionName == SocketOptionName.ReceiveTimeout)
                {
                    handle.ReceiveTimeout = optionValue == 0 ? -1 : optionValue;
                    return SocketError.Success;
                }
                else if (optionName == SocketOptionName.SendTimeout)
                {
                    handle.SendTimeout = optionValue == 0 ? -1 : optionValue;
                    return SocketError.Success;
                }
            }

            Interop.Error err = Interop.Sys.SetSockOpt(handle.FileDescriptor, optionLevel, optionName, (byte*)&optionValue, sizeof(int));
            return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketOptionErrorForErrorCode(err);
        }
开发者ID:jemmy655,项目名称:corefx,代码行数:19,代码来源:SocketPal.Unix.cs


示例18: Accept

 public static SocketError Accept(SafeCloseSocket handle, byte[] buffer, ref int nameLen, out SafeCloseSocket socket)
 {
     return SafeCloseSocket.Accept(handle, buffer, ref nameLen, out socket);
 }
开发者ID:jemmy655,项目名称:corefx,代码行数:4,代码来源:SocketPal.Unix.cs


示例19: Socket

        // Called by the class to create a socket to accept an incoming request.
        private Socket(SafeCloseSocket fd)
        {
            s_loggingEnabled = Logging.On;
            if (s_loggingEnabled)
            {
                Logging.Enter(Logging.Sockets, this, "Socket", null);
            }
            InitializeSockets();

            // NOTE: if this ctor is re-publicized/protected, check
            // that fd is valid socket handle.

            // This should never happen.
            if (fd == null || fd.IsInvalid)
            {
                throw new ArgumentException(SR.net_InvalidSocketHandle);
            }

            _handle = fd;

            _addressFamily = Sockets.AddressFamily.Unknown;
            _socketType = Sockets.SocketType.Unknown;
            _protocolType = Sockets.ProtocolType.Unknown;
            if (s_loggingEnabled)
            {
                Logging.Exit(Logging.Sockets, this, "Socket", null);
            }
        }
开发者ID:ReedKimble,项目名称:corefx,代码行数:29,代码来源:Socket.cs


示例20: Receive

        public static SocketError Receive(SafeCloseSocket handle, IList<ArraySegment<byte>> buffers, ref SocketFlags socketFlags, out int bytesTransferred)
        {
            SocketError errorCode;
            if (!handle.IsNonBlocking)
            {
                errorCode = handle.AsyncContext.Receive(buffers, ref socketFlags, handle.ReceiveTimeout, out bytesTransferred);
            }
            else
            {
                int socketAddressLen = 0;
                if (!TryCompleteReceiveFrom(handle.FileDescriptor, buffers, socketFlags, null, ref socketAddressLen, out bytesTransferred, out socketFlags, out errorCode))
                {
                    errorCode = SocketError.WouldBlock;
                }
            }

            return errorCode;
        }
开发者ID:jemmy655,项目名称:corefx,代码行数:18,代码来源:SocketPal.Unix.cs



注:本文中的SafeCloseSocket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SafeCurlHandle类代码示例发布时间:2022-05-24
下一篇:
C# SafeCertContextHandle类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap