public void StartRecive() { while (true) { int size = gameSocket.Receive(buffers); LogTool.GetInstance().Log("接收服务器的消息{0}", Encoding.UTF8.GetString(buffers, 0, size)); } }
public override void Initialize() { gameSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); gameSocket.Connect(new IPEndPoint(IPAddress.Parse(IP), port)); LogTool.GetInstance().Log("连接成功,发送消息"); SendReq("First Msg from Client"); Thread t = new Thread(StartRecive); t.Start(); }