TCP client\server - client doesn't always read
问题 Client Code: TcpClient client = new TcpClient(); NetworkStream ns; private void Form1_Load(object sender, EventArgs e) { try { client.Connect("127.0.0.1", 560); ns = client.GetStream(); byte[] buffer = ReadFully(ns, client.Available); //working with the buffer... } catch { //displaying error... } } public static byte[] ReadFully(NetworkStream stream , int initialLength) { // If we've been passed an unhelpful initial length, just // use 32K. if (initialLength < 1) { initialLength = 32768; }