无连接可以作出,因为目标机器积极地拒绝它 [英] No connection could be made because the target machine actively refuses it

查看:248
本文介绍了无连接可以作出,因为目标机器积极地拒绝它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在C#中一个简单的Hello World TCP / IP客户端服务器应用程序,但无法让我的客户端连接。任何人都可以提供任何额外的故障排除步骤?我开始江郎才尽......

I'm working on a simple hello world TCP/IP client server app in C# and am unable to get my client to connect. Can anyone offer any additional troubleshooting steps? I'm starting to run out of ideas...

下面是code中的相关章节:

Here are the relevant sections of code:

服务器:

Console.Out.WriteLine("About to bind address");
IPAddress ipAd = IPAddress.Parse("127.0.0.1"); 
Console.Out.WriteLine("Choose a port to bind...");

String port = Console.In.ReadLine();
int iPort = Int32.Parse(port);

TcpListener myList = new TcpListener(ipAd, iPort);

myList.Start();

Console.WriteLine("The server is running at: "+myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");

Socket s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);

客户端:

Console.Out.WriteLine("enter address: ");
string address = Console.In.ReadLine();
Console.Out.WriteLine("enter port: ");
int port = Convert.ToInt32(Console.In.ReadLine());

TcpClient tcpclnt = new TcpClient();
Console.WriteLine("Connecting.....");

Console.Out.WriteLine("Address: " + address + ":" + port);
tcpclnt.Connect(address, port);

我能够从客户端计算机ping服务器,但我无法远程登录使用绑定端口的服务器。我已经尝试了各种端口(少数在低8000S和一些围绕40000)。我有禁用Windows防火墙在这两个系统。该系统被连接到一个路由器,该路由器不是在互联网上。我试过有和没有端口转发设定为指定的端口传入的请求转发给服务器机器没有影响。

I am able to ping the server from the client machine, however I am unable to telnet to the server using the bound port. I've tried a variety of ports (a few in the low 8000s and a few up around 40000). I have disable windows firewall on both systems. The systems are connected to a router which is not on the internet. I've tried with and without port forwarding set to forward incoming requests on the given port to the server machine with no effect.

这是我已经能够捕获唯一的例外是由客户端抛出:

The only exception that I've been able to trap is thrown by the client:

没有连接可以作出,因为   目标机器积极拒绝   吧。

No connection could be made because the target machine actively refuses it.

我查了的InnerException 但似乎有没有 - 这是基本的例外。莫非是吧?

I checked for an InnerException but it seems that there are none - that is the base exception. Could that be right?

不知道还有什么我应该看 - 任何其他故障诊断步骤将是有益的。

Not sure what else I should be looking at - any additional troubleshooting steps would be helpful.

谢谢!

推荐答案

在code以上是听请求回送地址的到来。这将有效地只收听网络连接,该网络只包括你的机器。

The code above is listening to request coming from the loopback address. This will effectively only listen to connection on that network, and that network only includes your machine.

您是否尝试过听必将从中连接应该是未来网络的地址?在本地网络中就应该像192.168.xx的或10.xxx

Have you tried listening to the address bound to the network from which the connection should be coming? On a local network it should be something like 192.168.x.x or 10.x.x.x

这篇关于无连接可以作出,因为目标机器积极地拒绝它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆