我制作了一个小型Windows服务,我需要从我自己的本地主机系统连接,但在运行应用程序时出现错误。由于目标计算机主动拒绝,无法建立连接127.0.0.1:8082
No connection could be made because the target machine actively refused it 127.0.0.1:8082
,而它在实时IP和端口号完美工作,但我需要测试它在localhost作为我不能访问实时运行的IP每次..
这里是我的代码...
byte[] data = new byte[1024];
string input, stringData;
String ip = "127.0.0.1";
Int32 port = 8082;
string path = "D:\\";
if (File.Exists("ipsettings.txt"))
{
File.Delete("ipsettings.txt");
}
IPAddress ipad = IPAddress.Parse(ip);
IPEndPoint ipend = new IPEndPoint(ipad, port);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
sock.Connect(ipend);
}
catch (Exception ex)
{
throw ex;
}
我在这一点上得到错误..
try
{
sock.Connect(ipend);
}
catch (Exception ex)
{
throw ex;
}
请帮我解决这个问题..提前 谢谢..
问问你的服务器它的问题是什么? –
@MartinJames sir这是本地主机,我的应用程序类型是在调试模式下运行的Windows服务 – Adi
“主动拒绝”听起来像是防火墙问题。 – Floris