Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

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,



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.

Share this answer
Mentioned the answer in above comment.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900