关于Tcp协议客户端往服务器端传值问题
客户端想传一个类到服务端去,该怎么传呀??
我是用TCP协议,
networkStream=this.tcpClient.GetStream();
string cmd ="hello";
//转化字符串为字节流格式
byte[] sendbuf=Encoding.UTF8.GetBytes(cmd);
//当前tcp流写入缓冲字节
if (networkStream.CanWrite)
networkStream.Write(sendbuf,0,sendbuf.Length);
这个类还是不能确定的 有没有这样的方法将实体类转化成字符串
这里是传string类型的,我现在想传一个实体类 不知道怎么下手,郁闷 !