/// <summary> /// 接收消息 /// </summary> /// <param name="clientSocket"></param> private static void ReceiveMessage(object clientSocket) { Socket myClientSocket = (Socket)clientSocket; ErlConnect erlConnect = ConnectManager.manager ().beginConnect (myClientSocket) as ErlConnect; ClientPort clientPort = new ClientPort (erlConnect); while (true) { try { //通过clientSocket接收数据 if (myClientSocket.Available > 0) { //connect.readLength(); clientPort.receive (); } //int receiveNumber = myClientSocket.Receive(result); //Console.WriteLine("接收客户端{0}消息{1}", myClientSocket.RemoteEndPoint.ToString(), Encoding.ASCII.GetString(result, 0, receiveNumber)); } catch (Exception ex) { Console.WriteLine (ex.Message); myClientSocket.Shutdown (SocketShutdown.Both); myClientSocket.Close (); break; } } }