异步接收程序的问题!
public UserClient(TcpClient client) //UserClient的构造函数{
this._client = client;
ns = _client.GetStream();
ns.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(streamReceive),null );
}
private void streamReceive(IAsyncResult ar) //回调函数
{
int BytesRead;
byte[] rcv;
BytesRead =ns.EndRead (ar);
if(BytesRead !=0)
{
rcv=new byte [BytesRead -1];
for (int i = 0; i < BytesRead; i++)
{
rcv[i] = buffer[i];
}
ns.BeginRead (buffer ,0,buffer.Length ,new AsyncCallback (streamReceive ),null );
}
}
这个程序有什么问题?为什么接收不了呢?