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


C# SocketError.ToString方法代码示例

本文整理汇总了C#中SocketError.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SocketError.ToString方法的具体用法?C# SocketError.ToString怎么用?C# SocketError.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketError的用法示例。


在下文中一共展示了SocketError.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        /// <summary>
        /// Create and return a new NetMQException with no Message containing the given SocketError and Exception.
        /// </summary>
        /// <param name="error">a SocketError that this exception will carry and expose via its ErrorCode property</param>
        /// <param name="innerException">an Exception that this exception will expose via its InnerException property</param>
        /// <returns>a new NetMQException</returns>
        
        public static NetMQException Create(SocketError error,  Exception innerException = null)
        {
            var errorCode = error.ToErrorCode();

#if DEBUG
            if (errorCode == 0)
            {
                var s = string.Format("(And within NetMQException.Create: Unanticipated error-code: {0})", error.ToString());
                return Create(errorCode: errorCode, message: s, innerException: innerException);
            }
#endif

            return Create(errorCode, innerException);
        }
开发者ID:awb99,项目名称:netmq,代码行数:21,代码来源:NetMQException.cs

示例2: CheckAsyncCallOverlappedResult

        // This method is called after an asynchronous call is made for the user.
        // It checks and acts accordingly if the IO:
        // 1) completed synchronously.
        // 2) was pended.
        // 3) failed.
        internal unsafe SocketError CheckAsyncCallOverlappedResult(SocketError errorCode)
        {
            GlobalLog.Print(
                "BaseOverlappedAsyncResult#" + LoggingHash.HashString(this) +
                "::CheckAsyncCallOverlappedResult(" + errorCode.ToString() + ")");

            if (errorCode == SocketError.Success || errorCode == SocketError.IOPending)
            {
                // Ignore cases in which a completion packet will be queued:
                // we'll deal with this IO in the callback.
                return SocketError.Success;
            }

            // In the remaining cases a completion packet will NOT be queued:
            // we have to call the callback explicitly signaling an error.
            ErrorCode = (int)errorCode;
            Result = -1;

            ReleaseUnmanagedStructures();  // Additional release for the completion that won't happen.
            return errorCode;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:26,代码来源:BaseOverlappedAsyncResult.cs

示例3: UpdateStatusAfterSocketError

        internal void UpdateStatusAfterSocketError(SocketError errorCode)
        {
            // If we already know the socket is disconnected
            // we don't need to do anything else.
            GlobalLog.Print("Socket#" + Logging.HashString(this) + "::UpdateStatusAfterSocketError(socketException)");
            if (s_loggingEnabled)
            {
                Logging.PrintError(Logging.Sockets, this, "UpdateStatusAfterSocketError", errorCode.ToString());
            }

            if (_isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock &&
                    errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable &&
                    errorCode != SocketError.TimedOut)))
            {
                // The socket is no longer a valid socket.
                GlobalLog.Print("Socket#" + Logging.HashString(this) + "::UpdateStatusAfterSocketError(socketException) Invalidating socket.");
                SetToDisconnected();
            }
        }
开发者ID:ReedKimble,项目名称:corefx,代码行数:19,代码来源:Socket.cs

示例4: Create

        public static NetMQException Create(SocketError error, [CanBeNull] Exception innerException = null)
        {
            ErrorCode errorCode;

            switch (error)
            {
                case SocketError.AccessDenied:
                    errorCode = ErrorCode.AccessDenied;
                    break;
                case SocketError.Fault:
                    errorCode = ErrorCode.Fault;
                    break;
                case SocketError.InvalidArgument:
                    errorCode = ErrorCode.Invalid;
                    break;
                case SocketError.TooManyOpenSockets:
                    errorCode = ErrorCode.TooManyOpenSockets;
                    break;
                case SocketError.InProgress:
                    errorCode = ErrorCode.TryAgain;
                    break;
                case SocketError.MessageSize:
                    errorCode = ErrorCode.MessageSize;
                    break;
                case SocketError.ProtocolNotSupported:
                    errorCode = ErrorCode.ProtocolNotSupported;
                    break;
                case SocketError.AddressFamilyNotSupported:
                    errorCode = ErrorCode.AddressFamilyNotSupported;
                    break;
                case SocketError.AddressNotAvailable:
                    errorCode = ErrorCode.AddressNotAvailable;
                    break;
                case SocketError.NetworkDown:
                    errorCode = ErrorCode.NetworkDown;
                    break;
                case SocketError.NetworkUnreachable:
                    errorCode = ErrorCode.NetworkUnreachable;
                    break;
                case SocketError.NetworkReset:
                    errorCode = ErrorCode.NetworkReset;
                    break;
                case SocketError.ConnectionAborted:
                    errorCode = ErrorCode.ConnectionAborted;
                    break;
                case SocketError.ConnectionReset:
                    errorCode = ErrorCode.ConnectionReset;
                    break;
                case SocketError.NoBufferSpaceAvailable:
                    errorCode = ErrorCode.NoBufferSpaceAvailable;
                    break;
                case SocketError.NotConnected:
                    errorCode = ErrorCode.NotConnected;
                    break;
                case SocketError.TimedOut:
                    errorCode = ErrorCode.TimedOut;
                    break;
                case SocketError.ConnectionRefused:
                    errorCode = ErrorCode.ConnectionRefused;
                    break;
                case SocketError.HostUnreachable:
                    errorCode = ErrorCode.HostUnreachable;
                    break;
                default:
                    errorCode = 0; // to indicate no valid SocketError.
            #if DEBUG
                    string s = string.Format("(And within NetMQException.Create: Unanticipated error-code: {0})", error.ToString());
                    return Create(errorCode: errorCode, message: s, innerException: innerException);
            #else
                    break;
            #endif
            }

            return Create(errorCode, innerException);
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:75,代码来源:NetMQException.cs

示例5: UpdateStatusAfterSocketError

        internal void UpdateStatusAfterSocketError(SocketError errorCode)
        {
            // If we already know the socket is disconnected
            // we don't need to do anything else.
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print("Socket#" + LoggingHash.HashString(this) + "::UpdateStatusAfterSocketError(socketException)");
            }

            if (s_loggingEnabled)
            {
                NetEventSource.PrintError(NetEventSource.ComponentType.Socket, this, nameof(UpdateStatusAfterSocketError), errorCode.ToString());
            }

            if (_isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock &&
                    errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable &&
                    errorCode != SocketError.TimedOut)))
            {
                // The socket is no longer a valid socket.
                if (GlobalLog.IsEnabled)
                {
                    GlobalLog.Print("Socket#" + LoggingHash.HashString(this) + "::UpdateStatusAfterSocketError(socketException) Invalidating socket.");
                }

                SetToDisconnected();
            }
        }
开发者ID:MichalStrehovsky,项目名称:corefx,代码行数:27,代码来源:Socket.cs

示例6: OnReceiveResolved

        /// <summary>
        /// Gets called when a receive operation resolves.  If we were listening for data and the connection
        /// closed, that also counts as a receive operation resolving.
        /// </summary>
        /// <param name="args"></param>
        private void OnReceiveResolved(bool isUDP, byte[] buffer, int bytesReceived, SocketError status, SockState sockState)
        {
            SocketDebug(19);
            //// Log.LogMsg("==>++++ Async RECEIVE Op Completed - #" + ((SockState)args.UserToken).ID.ToString() + "#");
            try
            {
                if (!OwningConnection.IsAlive && bytesReceived > 0)
                {
                    SocketDebug(20);
                    return;
                }

                SocketDebug(21);
                // If there was a socket error, close the connection. This is NOT a normal
                // situation, if you get an error here.
                if (status != SocketError.Success)
                {
                    SocketDebug(22);
                    Log.LogMsg("Receive status = " + status.ToString());
                    if (!OwningConnection.ShuttingDown)
                    {
                        //// Log.LogMsg("Testy 111");
                        OwningConnection.KillConnection("Connection lost! Network receive error: " + status);
                    }
                    //Jump out of the ProcessReceive method.
                    SocketDebug(23);
                    return;
                }

                SocketDebug(24);
                m_TCPSockState.AsyncEventArgs.RemoteEndPoint = OwningConnection.MyTCPSocket.RemoteEndPoint;

                // If no data was received, close the connection. This is a NORMAL
                // situation that shows when the client has finished sending data.
                if (bytesReceived == 0)
                {
                    SocketDebug(25);
                    if (!OwningConnection.ShuttingDown)
                    {
                        //// Log.LogMsg("Testy 114");
                        OwningConnection.KillConnection("Connection closed by remote host.");
                    }
                    return;
                }

                SocketDebug(26);
                OwningConnection.ReceivedBytes(bytesReceived);

                // restart listening process
                SocketDebug(27);
                OwningConnection.AssembleInboundPacket(buffer, bytesReceived, sockState);
                SocketDebug(28);
            }
            catch (Exception ex)
            {
                Log.LogMsg("Error ProcessReceive. " + ex.Message);
                OwningConnection.KillConnection("Error receive. " + ex.Message);
            }
        }
开发者ID:kamilion,项目名称:WISP,代码行数:64,代码来源:DuplexBlockingTransitStrategy.cs

示例7: ProcessSocketError

        private void ProcessSocketError(Socket socket, SocketError socketError)
        {
            if (socketError == SocketError.Success)
            {
                // No problems here
                return;
            }

            if (socketError == SocketError.ConnectionReset)  // disconnect
            {
                if (this.RemoteDisconnect != null)
                {
                    this.RemoteDisconnect(socket, EventArgs.Empty);
                    return;  // That's all we need to do
                }
            }

            if (this.UnhandledSocketError != null)
            {
                this.UnhandledSocketError(socket, socketError);
                return;
            }

            Console.WriteLine(string.Format("Socket error: {0}", socketError.ToString()));

 //           throw new CommunicationException("Socket error: " + socketError.ToString(), new SocketException());
        }
开发者ID:bignis,项目名称:Trivia,代码行数:27,代码来源:SocketCommunicator.cs

示例8: Create

        public static NetMQException Create(SocketError error, [CanBeNull] Exception innerException = null)
        {
            var errorCode = error.ToErrorCode();

#if DEBUG
            if (errorCode == 0)
            {
                var s = $"(And within NetMQException.Create: Unanticipated error-code: {error.ToString()})";
                return Create(errorCode: errorCode, message: s, innerException: innerException);
            }
#endif

            return Create(errorCode, innerException);
        }
开发者ID:somdoron,项目名称:netmq,代码行数:14,代码来源:NetMQException.cs

示例9: ShouldRetryAccept

 bool ShouldRetryAccept(SocketError error)
 {
     if (error == SocketError.OperationAborted)
     {
         // Close/Abort was called
         return false;
     }
     else
     {
         AmqpTrace.Provider.AmqpListenSocketAcceptError(this, true, error.ToString());
         return true;
     }
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:13,代码来源:TcpTransportListener.cs


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