我正在尝试使用 C# 与网络中的远程系统建立连接。然后程序抛出以下异常
无法建立连接,因为目标机器主动拒绝它 192.168.1.42:8000
private void Start_Sending_Video_Conference(string remote_IP,int port_number)
{
try
{
ms = new MemoryStream();// Store it in Binary Array as
pictureBox1.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arrImage = ms.GetBuffer();
myclient = new TcpClient (remote_IP,port_number);//Connecting with server
myns = myclient.GetStream ();
mysw = new BinaryWriter (myns);
mysw.Write(arrImage);//send the stream to above address
ms.Flush();
mysw.Flush();
myns.Flush();
ms.Close();
mysw.Close ();
myns.Close ();
myclient.Close ();
}
catch (Exception ex)
{
Capturing.Enabled = false;
MessageBox.Show(ex.Message, "Video Conference Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}