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


C# Sockets.SafeCloseSocket类代码示例

本文整理汇总了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));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:SafeCloseSocket.Windows.cs

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

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

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

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

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

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

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

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

示例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
        }
开发者ID:naamunds,项目名称:corefx,代码行数:14,代码来源:SafeNativeOverlapped.cs

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

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

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

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

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


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