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

C# SocketError类代码示例

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

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



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

示例1: ReceiveChunk

		public unsafe void ReceiveChunk(string endpoint, bool isAlive, int bytesReceived, SocketError status)
		{
			if (IsEnabled())
			{
				fixed (char* pEndpoint = endpoint)
				{
					var data = stackalloc EventData[4];

					data[0].DataPointer = (IntPtr)(pEndpoint);
					data[0].Size = (endpoint.Length + 1) * 2;

					var alive = isAlive ? 1 : 0;
					data[1].DataPointer = (IntPtr)(&alive);
					data[1].Size = sizeof(int);

					data[2].DataPointer = (IntPtr)(&bytesReceived);
					data[2].Size = sizeof(int);

					data[3].Size = sizeof(int);
					data[3].DataPointer = (IntPtr)(&status);

					WriteEventCore(22, 4, data);
				}
			}
		}
开发者ID:adamhathcock,项目名称:EnyimMemcached2,代码行数:25,代码来源:AsyncSocket.cs


示例2: InitOption

 private void InitOption(MailStatus status, MailCause cause)
 {
     this.mStatus = status;
     this.mCause = cause;
     this.mSocketErrorCode = 0;
     this.mSocketErrorCodeType = SocketError.Success;
 }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:7,代码来源:MailExceptionEx.cs


示例3: OnConnectionFailed

 private void OnConnectionFailed(ITcpConnection connection, SocketError socketError)
 {
     if (Interlocked.CompareExchange(ref _isClosed, 1, 0) == 0)
     {
         Console.WriteLine("Connection '{0}' ({1:B}) to [{2}] failed: {3}.", _connectionName, _connectionId, connection.RemoteEndPoint, socketError);
     }
 }
开发者ID:Cocotus,项目名称:SocketAsyncSample,代码行数:7,代码来源:SocketClient.cs


示例4: InCompleted

        public void InCompleted(SocketError socketError, int bytesTransferred)
        {
            if (socketError != SocketError.Success)
            {
                m_socket.EventAcceptFailed(m_address.ToString(), ErrorHelper.SocketErrorToErrorCode(socketError));

                // dispose old object
                m_acceptedSocket.Handle.Dispose();

                Accept();
            }
            else
            {
                m_acceptedSocket.InitOptions();

                var pgmSession = new PgmSession(m_acceptedSocket, m_options);

                IOThread ioThread = ChooseIOThread(m_options.Affinity);

                SessionBase session = SessionBase.Create(ioThread, false, m_socket, m_options, new Address(m_handle.LocalEndPoint));

                session.IncSeqnum();
                LaunchChild(session);
                SendAttach(session, pgmSession, false);
                m_socket.EventAccepted(m_address.ToString(), m_acceptedSocket.Handle);

                Accept();
            }
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:29,代码来源:PgmListener.cs


示例5: OnClientDisconnect

 private void OnClientDisconnect(ServerClient arg1, SocketError arg2)
 {
     Console.WriteLine("Disconnected");
     _timeSyncCompleted = false;
     _completedEvent.Set();
     _batchCounter = 0;
 }
开发者ID:jmptrader,项目名称:SharpMessaging,代码行数:7,代码来源:LoadTestServer.cs


示例6: OnConnectionClosed

 private void OnConnectionClosed(ITcpConnection connection, SocketError socketError)
 {
     if (Interlocked.CompareExchange(ref _isClosed, 1, 0) == 0)
     {
         Console.WriteLine("Connection '{0}' [{1:B}] closed: {2}.", connection.ConnectionId, connection.RemoteEndPoint, socketError);
     }
 }
开发者ID:Cocotus,项目名称:SocketAsyncSample,代码行数:7,代码来源:AcceptedConnection.cs


示例7: Connect

        /// <summary>
        /// Connect TCP socket to a server.
        /// </summary>
        /// <param name="serverAddr">IP or hostname of server.</param>
        /// <param name="port">Port that TCP should use.</param>
        /// <returns>True if connection is successful otherwise false</returns>
        internal bool Connect(string serverAddr, int port)
        {
            try
            {
                IPAddress[] serverIP = Dns.GetHostAddresses(serverAddr);
                if (serverIP.Length <= 0)
                {
                    mErrorString = "Error looking up host name";
                    return false;
                }

                mTCPClient = new TcpClient();
                mTCPClient.Connect(serverIP[0], port);
                // Disable Nagle's algorithm
                mTCPClient.NoDelay = true;
            }
            catch (SocketException e)
            {
                mErrorString = e.Message;
                mErrorCode = e.SocketErrorCode;

                if (mTCPClient != null)
                {
                    mTCPClient.Close();
                }

                return false;
            }

            return true;
        }
开发者ID:qualisys,项目名称:RTClientSDK.Net,代码行数:37,代码来源:RTNetwork.cs


示例8: CheckAsyncCallOverlappedResult

 internal SocketError CheckAsyncCallOverlappedResult(SocketError errorCode)
 {
     if (this.m_UseOverlappedIO)
     {
         switch (errorCode)
         {
             case SocketError.Success:
             case SocketError.IOPending:
                 ThreadPool.UnsafeRegisterWaitForSingleObject(this.m_OverlappedEvent, new WaitOrTimerCallback(this.OverlappedCallback), this, -1, true);
                 return SocketError.Success;
         }
         base.ErrorCode = (int) errorCode;
         base.Result = -1;
         this.ReleaseUnmanagedStructures();
         return errorCode;
     }
     this.ReleaseUnmanagedStructures();
     switch (errorCode)
     {
         case SocketError.Success:
         case SocketError.IOPending:
             return SocketError.Success;
     }
     base.ErrorCode = (int) errorCode;
     base.Result = -1;
     if (this.m_Cache != null)
     {
         this.m_Cache.Overlapped.AsyncResult = null;
     }
     this.ReleaseUnmanagedStructures();
     return errorCode;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:BaseOverlappedAsyncResult.cs


示例9: OnConnectionClosed

        private void OnConnectionClosed(ITcpConnection connection, SocketError socketError)
        {
            connection.ConnectionClosed -= OnConnectionClosed;

            var handler = ConnectionClosed;
            if (handler != null)
                handler(this, socketError);
        }
开发者ID:jpierson,项目名称:EventStore,代码行数:8,代码来源:TcpTypedConnection.cs


示例10: AcceptCompletionCallback

        private void AcceptCompletionCallback(IntPtr acceptedFileDescriptor, byte[] socketAddress, int socketAddressSize, SocketError socketError)
        {
            _acceptedFileDescriptor = acceptedFileDescriptor;
            Debug.Assert(socketAddress == null || socketAddress == _acceptBuffer, $"Unexpected socketAddress: {socketAddress}");
            _acceptAddressBufferCount = socketAddressSize;

            CompletionCallback(0, socketError);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:8,代码来源:SocketAsyncEventArgs.Unix.cs


示例11: SocketException

        internal SocketException(SocketError errorCode, uint platformError) : base((int)platformError)
        {
            _errorCode = errorCode;

            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print($"SocketException::.ctor(SocketError={errorCode}, uint={platformError}):{Message}");
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:9,代码来源:SocketException.Unix.cs


示例12: SocketException

        /// <summary>Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the specified error code as SocketError.</summary>
        internal SocketException(SocketError socketError) : base(GetNativeErrorForSocketError(socketError))
        {
            _errorCode = socketError;

            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print($"SocketException::.ctor(SocketError={socketError}):{Message}");
            }
        }
开发者ID:benpye,项目名称:corefx,代码行数:10,代码来源:SocketException.cs


示例13: Close

 public override bool Close () {
     try {
         socket.Close();
         return true;
     } catch (SocketException exn) {
         socketError = exn.SocketErrorCode;
         return false;
     }
 }
开发者ID:karlgluck,项目名称:udpkit,代码行数:9,代码来源:udpPlatformManaged.cs


示例14: CompletionStatus

 internal CompletionStatus(AsyncSocket asyncSocket, object state, OperationType operationType, SocketError socketError, int bytesTransferred) : 
     this()
 {
     AsyncSocket = asyncSocket;
     State = state;
     OperationType = operationType;
     SocketError = socketError;
     BytesTransferred = bytesTransferred;
 }
开发者ID:awb99,项目名称:AsyncIO,代码行数:9,代码来源:CompletionStatus.cs


示例15: CompletionCallback

        public void CompletionCallback(int numBytes, byte[] socketAddress, int socketAddressSize, SocketFlags receivedFlags, SocketError errorCode)
        {
            if (_socketAddress != null)
            {
                Debug.Assert(socketAddress == null || _socketAddress.Buffer == socketAddress);
                _socketAddressSize = socketAddressSize;
            }

            base.CompletionCallback(numBytes, errorCode);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:OverlappedAsyncResult.Unix.cs


示例16: AcceptCompletionCallback

        private void AcceptCompletionCallback(int acceptedFileDescriptor, byte[] socketAddress, int socketAddressSize, SocketError socketError)
        {
            // TODO: receive bytes on socket if requested

            _acceptedFileDescriptor = acceptedFileDescriptor;
            Debug.Assert(socketAddress == null || socketAddress == _acceptBuffer);
            _acceptAddressBufferCount = socketAddressSize;

            CompletionCallback(0, socketError);
        }
开发者ID:vbouret,项目名称:corefx,代码行数:10,代码来源:SocketAsyncEventArgs.Unix.cs


示例17: GetDesc

        public static string GetDesc(SocketError e)
        {
            switch(e)
            {
                case SocketError.Success: return "The Socket operation succeeded.";
                case SocketError.SocketError: return "An unspecified Socket error has occurred.";
                case SocketError.Interrupted: return "A blocking Socket call was canceled.";
                case SocketError.AccessDenied: return "An attempt was made to access a Socket in a way that is forbidden by its access permissions.";
                case SocketError.Fault: return "An invalid pointer address was detected by the underlying socket provider.";
                case SocketError.InvalidArgument: return "An invalid argument was supplied to a Socket member.";
                case SocketError.TooManyOpenSockets: return "There are too many open sockets in the underlying socket provider.";
                case SocketError.WouldBlock: return "An operation on a nonblocking socket cannot be completed immediately.";
                case SocketError.InProgress: return "A blocking operation is in progress.";
                case SocketError.AlreadyInProgress: return "The nonblocking Socket already has an operation in progress.";
                case SocketError.NotSocket: return "A Socket operation was attempted on a non-socket.";
                case SocketError.DestinationAddressRequired: return "A required address was omitted from an operation on a Socket.";
                case SocketError.MessageSize: return "The datagram is too long.";
                case SocketError.ProtocolType: return "The protocol type is incorrect for this Socket.";
                case SocketError.ProtocolOption: return "An unknown, invalid, or unsupported option or level was used with a Socket.";
                case SocketError.ProtocolNotSupported: return "The protocol is not implemented or has not been configured.";
                case SocketError.SocketNotSupported: return "The support for the specified socket type does not exist in this address family.";
                case SocketError.OperationNotSupported: return "The address family is not supported by the protocol family.";
                case SocketError.ProtocolFamilyNotSupported: return "The protocol family is not implemented or has not been configured.";
                case SocketError.AddressFamilyNotSupported: return "The address family specified is not supported. This error is returned if the IPv6 address family was specified and the IPv6 stack is not installed on the local machine. This error is returned if the IPv4 address family was specified and the IPv4 stack is not installed on the local machine.";
                case SocketError.AddressAlreadyInUse: return "Only one use of an address is normally permitted.";
                case SocketError.AddressNotAvailable: return "The selected IP address is not valid in this context.";
                case SocketError.NetworkDown: return "The network is not available.";
                case SocketError.NetworkUnreachable: return "No route to the remote host exists.";
                case SocketError.NetworkReset: return "The application tried to set KeepAlive on a connection that has already timed out.";
                case SocketError.ConnectionAborted: return "The connection was aborted by the .NET Framework or the underlying socket provider.";
                case SocketError.ConnectionReset: return "The connection was reset by the remote peer.";
                case SocketError.NoBufferSpaceAvailable: return "No free buffer space is available for a Socket operation.";
                case SocketError.IsConnected: return "The Socket is already connected.";
                case SocketError.NotConnected: return "The application tried to send or receive data, and the Socket is not connected.";
                case SocketError.Shutdown: return "A request to send or receive data was disallowed because the Socket has already been closed.";
                case SocketError.TimedOut: return "The connection attempt timed out, or the connected host has failed to respond.";
                case SocketError.ConnectionRefused: return "The remote host is actively refusing a connection.";
                case SocketError.HostDown: return "The operation failed because the remote host is down.";
                case SocketError.HostUnreachable: return "There is no network route to the specified host.";
                case SocketError.ProcessLimit: return "Too many processes are using the underlying socket provider.";
                case SocketError.SystemNotReady: return "The network subsystem is unavailable.";
                case SocketError.VersionNotSupported: return "The version of the underlying socket provider is out of range.";
                case SocketError.NotInitialized: return "The underlying socket provider has not been initialized.";
                case SocketError.Disconnecting: return "A graceful shutdown is in progress.";
                case SocketError.TypeNotFound: return "The specified class was not found.";
                case SocketError.HostNotFound: return "No such host is known. The name is not an official host name or alias.";
                case SocketError.TryAgain: return "The name of the host could not be resolved. Try again later.";
                case SocketError.NoRecovery: return "The error is unrecoverable or the requested database cannot be located.";
                case SocketError.NoData: return "The requested name or IP address was not found on the name server.";
                case SocketError.IOPending: return "The application has initiated an overlapped operation that cannot be completed immediately.";
                case SocketError.OperationAborted: return "The overlapped operation was aborted due to the closure of the Socket.";
            }

            return "Unknown Socket Error";
        }
开发者ID:DieterKoblenz,项目名称:LCARS,代码行数:55,代码来源:SocketErrorDesc.cs


示例18: IsIgnorableError

 // http://msdn.microsoft.com/ko-kr/library/vstudio/system.net.sockets.socketerror(v=vs.100).aspx
 public static bool IsIgnorableError(SocketError error)
 {
     if (error == SocketError.Interrupted
         || error == SocketError.ConnectionAborted
         || error == SocketError.ConnectionReset
         || error == SocketError.OperationAborted)
     {
         return true;
     }
     return false;
 }
开发者ID:jungrok5,项目名称:BitBox,代码行数:12,代码来源:SocketEx.cs


示例19: CompletionCallback

        public void CompletionCallback(int numBytes, byte[] socketAddress, int socketAddressSize, SocketFlags receivedFlags, IPPacketInformation ipPacketInformation, SocketError errorCode)
        {
            Debug.Assert(_socketAddress != null);
            Debug.Assert(socketAddress == null || _socketAddress.Buffer == socketAddress);

            _socketAddressSize = socketAddressSize;
            _socketFlags = receivedFlags;
            _ipPacketInformation = ipPacketInformation;

            base.CompletionCallback(numBytes, errorCode);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:ReceiveMessageOverlappedAsyncResult.Unix.cs


示例20: Handle

 void Handle( SocketError se )
 {
     switch ( se ) {
     case SocketError.Success:
         return; // not an error
     case SocketError.ConnectionReset:
         if (AutoReconnect) BeginReconnect();
         break;
     }
     if ( OnSocketError != null ) OnSocketError(se);
 }
开发者ID:MaulingMonkey,项目名称:uberirc,代码行数:11,代码来源:IrcConnection.Errors.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SocketFlags类代码示例发布时间:2022-05-24
下一篇:
C# SocketClient类代码示例发布时间: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