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


C# SocketAsyncEventArgs.ToString方法代码示例

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


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

示例1: SendTurnAsync_Completed

 private void SendTurnAsync_Completed(Socket socket, SocketAsyncEventArgs e)
 {
     if (e.SocketError != SocketError.Success)
         logger.WriteWarning(String.Format(@"SendTurn Failed\r\nSocket Type {0}:\r\nError: {1}", socket.SocketType.ToString(), e.ToString()));
 }
开发者ID:vf1,项目名称:turnserver,代码行数:5,代码来源:TurnServer.cs

示例2: ClientAccepted

        /// <summary>
        /// 연결 수립시
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClientAccepted(object sender, SocketAsyncEventArgs e)
        {
            // 클라이언트 소켓 얻기
            logln("연결 요청 확인됨.", true);
            Socket clientSock = e.AcceptSocket;

            if (clientSock != null && clientSock is Socket)
            {
                // 소켓 데이터 설정
                logln("대상: " + clientSock.RemoteEndPoint.ToString(), true);
                SocketAsyncEventArgs recvE = new SocketAsyncEventArgs();

                // 소켓 데이터 초기화
                SocketData data = new SocketData();
                data.initData(1024);

                recvE.UserToken = data;
                recvE.SetBuffer(data.Data, 0, 1024);
                recvE.Completed += new EventHandler<SocketAsyncEventArgs>(ReceiveCompleted);
                clientSock.ReceiveAsync(recvE);

                // 뷰어 초기화
                Viewer viewer = new Viewer();
                viewer.Socket = clientSock;
                viewer.SocketData = data;
                Viewers.Add(viewer);
            }
            else
            {
                logln("연결을 수립하는 중 에러 발생\n" + e.ToString(), true, true);
            }

            // 다음 연결 수립 대기
            Socket server = sender as Socket;
            e.AcceptSocket = null;
            server.AcceptAsync(e);
        }
开发者ID:Honsal,项目名称:ChatServer,代码行数:42,代码来源:TcpIPServer.cs

示例3: SocketAsyncEventArgs_Completed

        /// <summary>
        /// Client connected.
        /// </summary>
        private void SocketAsyncEventArgs_Completed(object sender, SocketAsyncEventArgs e)
        {
            try
            {
                if (e.SocketError != SocketError.Success)
                {// This will execute the finally block, but skip the AssignAsyncAcceptArgs().
                    return;
                }

                if (e.LastOperation == SocketAsyncOperation.Accept
                    && e.SocketError == SocketError.Success)
                {
                    SocketCommunicatorEx helper = new SocketCommunicatorEx(_serializer);
                    helper.AssignSocket(e.AcceptSocket, true);
                    helper.Id = PendingClientId;

            #if Matrix_Diagnostics
                    helper.Monitor.MinimumTracePriority = Monitor.MinimumTracePriority;
            #endif

                    helper.ConnectedEvent += new SocketCommunicator.HelperUpdateDelegate(helper_ConnectedEvent);
                    helper.DisconnectedEvent += new SocketCommunicator.HelperUpdateDelegate(helper_DisconnectedEvent);

                    helper.MessageReceivedEvent += new SocketCommunicator.MessageUpdateDelegate(helper_MessageReceivedEvent);
                    helper.SendAsyncCompleteEvent += new SocketCommunicator.AsyncMessageSendDelegate(helper_SendAsyncCompleteEvent);

                    _clientsHotSwap[(int)helper.Id] = helper;

            #if Matrix_Diagnostics
                    Monitor.ReportImportant("Client [" + helper.Id + "] connected.");
            #endif

                    ServerClientUpdateDelegate delegateInstance = ClientConnectedEvent;
                    if (delegateInstance != null)
                    {
                        delegateInstance(this, helper);
                    }
                }
                else
                {
            #if Matrix_Diagnostics
                    Monitor.NotImplementedWarning(e.ToString());
            #endif
                }

            }
            finally
            {
                e.Completed -= new EventHandler<SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);
                e.Dispose();
            }

            AssignAsyncAcceptArgs();
        }
开发者ID:paralin,项目名称:SuperPool,代码行数:57,代码来源:SocketMessageServer.cs


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