C# TCP连接由于目标机器积极拒绝,无法连接
防火墙已经关闭了,端口7800也已经添加了,可还是出现由于目标机器积极拒绝,无法连接,下面是代码privateTcpClientm_clientTcp;privateNe...
防火墙已经关闭了,端口7800也已经添加了,可还是出现由于目标机器积极拒绝,无法连接,下面是代码
private TcpClient m_clientTcp;
private NetworkStream networkstream;
byte[] data=new byte[112];
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(ipadd), int.Parse(port));//服务器的IP和端口
try
{
m_clientTcp = new TcpClient();
m_clientTcp.Connect(ipep);
networkstream = m_clientTcp.GetStream();
}
catch (SocketException e)
{
MessageBox.Show("不能连接到服务器\n"+e.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
请问会是什么问题?谢谢 展开
private TcpClient m_clientTcp;
private NetworkStream networkstream;
byte[] data=new byte[112];
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(ipadd), int.Parse(port));//服务器的IP和端口
try
{
m_clientTcp = new TcpClient();
m_clientTcp.Connect(ipep);
networkstream = m_clientTcp.GetStream();
}
catch (SocketException e)
{
MessageBox.Show("不能连接到服务器\n"+e.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
请问会是什么问题?谢谢 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询