无法建立连接,因为目标计算机主动拒绝它WIN​​DOWS 7 [英] Connection could not be made because the target machine actively refused it WINDOWS 7

查看:123
本文介绍了无法建立连接,因为目标计算机主动拒绝它WIN​​DOWS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Windows 7中遇到TCP事务问题。



我有使用TCP套接字编程创建示例客户端应用程序和服务器应用程序。



使用端口作为2001设置localhost(我的计算机IP)作为IP地址,我试图从客户端到服务器。

使用netstat命令我发现2001端口没有分配给任何东西。





在服务器接收之后,我正在尝试从客户端发送简单的消息。



我收到消息因为目标机器主动拒绝它而无法建立连接。



我已经禁用了Windows防火墙,但仍然遇到同样的错误。



相同的设置是为Windows XP工作。





任何人都可以解释我需要做什么设置才能进行通信。





先谢谢,



Vijay

Hi,

I am facing problem in Windows 7 for TCP transaction.

I have created sample client application and server application using TCP Socket programming.

Using port as 2001 setting localhost(My computer IP) as IP address, I am trying to send message from client to server.
Using the netstat command I found that 2001 port is not assigned to anything.


After making server to receive, I am trying to send simple msg from client.

I am getting message as "No Connection could be made because target machine actively refused it".

I have disabled the Windows firewall and still getting the same error.

Same setting is working for Windows XP.


Anyone please explain what setting I should need to do for enabling the communication.


Thanks in Advance,

Vijay

推荐答案

对不起。



我自己找到了答案。



我正在使用一个IP地址从服务器打开端口,我试图使用不同的IP地址从客户端打开同一个端口导致错误。



这不是因为Windows7操作系统。





还有一些我们需要注意的事项。



首先我在Windows XP中测试了上面的TCP通信它运行正常,但没有使用windows7。 />




原因是

在服务器端,我使用的是System.Net.Dns.GetHostEntry(主机名) )获取我正在打开port的Ipv4地址。从客户端也可以通过输入我的IP地址打开相同的端口。



如上所述在XP中会给出Ipv4地址,它工作正常。



但在Windows 7中(支持IPV6) ,上面的函数给出了Ipv6的默认地址,即:: 1。



从客户端我键入的计算机IPV4地址与:: 1不同导致了错误。





如果我们看到MSDN System.Net.Dns.GetHostEntry(主机名)没有提及IPV6的任何内容。



任何人都想使用上述功能请保重。



Vijay
Sorry.

I found the answer by myself.

I was opening port from server using one IP address and I was trying to open same port from client using different IP address which was the cause for the error.

It is not because of Windows7 OS.


Still there is something we need to take care.

First I tested the above TCP communication in windows XP it was working fine but not with windows7.


Reason for this is
In server side, I was using System.Net.Dns.GetHostEntry(hostname) to get the Ipv4 adress by which I am opening port.From client side also I used to open the same port by typing my IP address.

As the above function in XP will give the Ipv4 address, it was working fine.

But in windows 7(which support IPV6), the above function gives Ipv6 default address i.e ::1.

From client side I am typing my computer IPV4 address which was different from ::1 that led to the error.


If we see MSDN System.Net.Dns.GetHostEntry(hostname) doesn''t mention anything about IPV6.

Anyone want to use the above function please take care.

Vijay


在上面的评论中提到答案。
Mentioned the answer in above comment.


这篇关于无法建立连接,因为目标计算机主动拒绝它WIN​​DOWS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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