connect External socket

Hey all,
So I am having an issue with connecting to a external socket
int iResult = connect(ExternalSocket, (struct sockaddr *) &caddr, sizeof(SOCKADDR));
int LastError = WSAGetLastError();

Above is some test code I have used to get what error is being thrown, what keeps happening is the error WSAETIMEDOUT is returned.

I have had issues with this so far on windows 7 64 bit.

If any one could throw any info my way would be great, I am thinking its a registry issue.

Thank you so much in advance
Sorry to do this to you but we need to cover the basics first. Can you ping the target host from the machine you're running the client side app from? Are you certain that the server side application is running on the target host? Are the firewalls off on both machines (this isn't 100% necessary but it rules them out as a cause to this problem)? Is the server side app listening on the same socket?
that's okay most of the time its all ways the simple things which cause this.

- Stopped windows firewall service

Even when the firewall is disabled I still could not ping, found this to be the file and printer sharing needed to be enabled to be able to ping it. Found this out a few hours ago.

And you process? Any luck getting it to work?
When running my App Win 7 connecting to another APP on Win 7 the error is WSAETIMEDOUT

Tried App on a Win XP connecting to another App on Win XP and the combination on Win AP to Win 7 and found the error return is this

It sounds like your Server side is not responding correctly. On the PC running the Server application open a command prompt and type netstat -a -b and look for the name of your executable to make sure that it is in the 'LISTENING' state and double check which port it is listening on.
Thank you very much for the help ComputerGeek01, I managed to get a bit more info.

Okay bit of an update (a:Win 7 to b:win 7) using the above cmd i can see that A:Win7 sent a packet to the correct IP and port.

However on the state on a:Win7 is SYN_SENT which means its ignoring the packet now on B:win7 it is listening on the correct port but has for the IP bit (Both units are using WLAN).

If b:Win7 sends a packet to a:win7 the App works perfect..... I think more investigation is needed.

Bit more of an update i can ping the a:Win7 i tired connecting to the cannot RDP Port and says can not open port to the host.
This is wrong!
int iResult = connect(ExternalSocket, (struct sockaddr *) &caddr, sizeof(SOCKADDR));

It should be:
int iResult = connect(ExternalSocket, (struct sockaddr *) &caddr, sizeof(caddr));
struct sockaddr_in caddr ;
is declared above

Found part of the issue


I was doing this test which will be false as iResult return 0 when it succeeds noob error :P

I will let you know how i get on
so enabling file and printer sharing and disabling the firewall did the trick!
It wouldn't have worked with that wrong size passed into connect.
Everything works now needed to allow icmp for pings as this is part of file and printer sharing. And allow the port we are using. Thank you for all your help guys
Topic archived. No new replies allowed.