views:

40

answers:

1

I'm working on a client/server and I'm having trouble getting them to communicate over the internet. If I'm running them on the same computer, it works fine if I have the client connect to localhost or to my network address (192.168.1...), but it doesn't work (Error 10061: connection actively refused) if I have the client connect to my external address (99.141...). I've tried turning my firewall off and I've forwarded the ports on the router, so I don't really know what else to check. The server is made with the TcpListener class and the client is made with the TcpClient class. The server is bound to IPAddress::Any.

I checked netstat and the server is broadcasting on the correct port, I just can't connect to it non-locally.

+1  A: 

Have you turned on port forwarding on the external address, 99.141.x.x, for example, the client is connecting to port 901, it works on the private Class C network address such as 192.168.1.x, have you turned on the external address 99.141.x.x:901, so that it can send data in and out.... are you running the server behind the firewall at the external address 99.141.x.x:901?

Accordingly to the MSDN documentation for Winsock error, 10061 is Connection Refused...somewhere down the line, the client attempted to connect but got rejected...

It would help to run WireShark and investigate the packets if they are actually being transmitted...

More than likely the ISP has blocked incoming bound data packets....

tommieb75
I installed WireShark and ran it while I tried to connect, but I'm not exactly sure what I'm looking at. It LOOKS like the connection is being sent out and received properly, but the ports look wrongI have a packet from 192.168.1.75 going to 99.141.65.30 with a source port of 4364 and a destination port of 13005 (presumably the client attempting to connect), and then another packet coming from 99.141.65.30 going to 192.168.1.75 with a source port of 13005 and a destination port of 4364 (presumably the connection coming back to the server), but I don't know why it's got that destination port.
Alex Zylman
When you connect out to a server, the client will use an available port to connect *from* - so a source port from the client of 4364 (and likewise the same port when the client is a destination) is fine.
Will A
So if the second packet was was back to the client, then would that mean that nothing was coming in sent for the server? Since I had "packet from client" followed by "packet to client" with no "packet to server", it seems like the client is never reaching the server. So somewhere either port forwarding is not set up properly or my ISP is filtering the port?
Alex Zylman
It *seems* like you have packet to server, packet from server, though, given the IP addresses.
Will A
Well, since the server is on the same computer as the client (just different ports) it should be looking something like: packet #1 out to server from client, packet #1 in to server from client, packet #2 out to client from server, packet #2 in to client from server. Right?
Alex Zylman