Home > Net >  C # Socket CBNet - FP Ethernet connection
C # Socket CBNet - FP Ethernet connection

Time:09-18

Can send data, but not receive data server port, listening is also an error (using the local IP port can send and receive data)
Try
{
TcpClient TcpClient=new TcpClient ();
TcpClient. Connect (IPAddress. Parse (textBox1. Text), Int32. Parse (textBox2. Text));
NetworkStream ns=tcpClient. GetStream ();
If (ns. CanWrite)
{
Byte [] sendBytes=Encoding. The Default. GetBytes (richTextBox2. Text);
Ns. Write (sendBytes, 0, sendBytes. Length);
TcpClient. Close ();
Ns. The Close ();
}
The else
{
MessageBox. Show (" cannot write data flow ");
TcpClient. Close ();
Ns. The Close ();
return;
}
}
The catch (Exception ex)
{
MessageBox. Show (ex. Message);
}
  •  Tags:  
  • C #
  • Related