private void tcp_send(string data)//tcp协议转发数据
{
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(IPAddress.Parse("127.0.0.1"), 8000);//发送的主机地址及端口
NetworkStream ntwStream = tcpClient.GetStream();
if (ntwStream.CanWrite)
{
Byte[] bytSend = Encoding.UTF8.GetBytes(data);
ntwStream.Write(bytSend, 0, bytSend.Length);
}
else
{
ntwStream.Close();
tcpClient.Close();
return;
}
ntwStream.Close();
tcpClient.Close();
}