难道.......只能在client端new一个大~~(65535...)数组么?

解决方案 »

  1.   

    NetworkStream 不支持 Length属性,如果调用,择会发生NotSupportedException异常,
    哈哈,你没有办法吧!!!!一般我是这样做的
      TcpClient tcpClient=new TcpClient(...);
      ....
      NetworkStream networkStream=tcpClient.GetStream();
      byte[] buf;
      if (networkStream.DataAvailable)
         {
          byte[] buf1=new byte[1024];
          int len=networkStream.Read(buf1,0,buf1.Length);
          if (len<buf1.Length)
             buf=buf1;
            else 
            //麻烦了..分块读,自己写啦
           最后把buf1。。bufn 连接起来,生产buf
      。
          
         
         }
      

  2.   

    UdpClient udpclient=new udpclient(5000);//服务
    IPHostPoint ipHostPoint;
    byte[] buf=updclient.Recive(ref ipHostPoint);
           buf.Length 这里可以,不用自己设定buf 的Length