当前位置: 首页>>代码示例>>C#>>正文


C# SafeCloseSocket类代码示例

本文整理汇总了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);
        }
开发者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


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