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


C# SocketError类代码示例

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


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


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