IdTCP client/server connection problem


I'm currently trying to make a program with Indy components. The idea is that people should be able to connect to a server via the internet with clients using TCP. The problem is that I can't get the whole connect thing to work over the internet.

How ever it works fine if the server and client is run on the same computer or the same intranet so it shouldn't be any problem with ports or something like that. Possibly it's a router problem but I would assume that it would get through something like that.

The error I get is "connection refused" and that would indicate that the client can't find the server even if it can find the IP. I have tried with IdSocksInfo but that only seemed to make things worse. Does anyone know what I'm doing wrong? Or alternatively: Does anyone have a simple example of a program that can communicate over the internet and through various proxies and other annoying things.

I can add more information about the setup if needed.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

MarcoMi66Connect With a Mentor Commented:
Yes Rohan you are right!
Even in P2P file sharing, if you are behind a firewall and no portmapping is provided (i.e. your IP/port cannot be reached FROM the Internet) you cannot exchange data with user in the same condition.
I think there is no way from solving it other than having a third machine that act like a governor.
If you can connect in the Intranet but you cannot connect through the Internet, the more reasonable problem should be some firewall protection.
For testing purposes just use the telnet command from the client PC.
telnet <ipaddress> <port> and:
 - if you receive a blank page it usually means that the connection has been estabilshed
 - if you receive an error (such as "Impossible to connect to host...) it means that no connection is possible.

If you are in the 2nd case (and i think so) here are some questions:
 - Has the server a public IP Address?
 - Is the server public IP Address reacheble by Internet?
 - Has the Server some other service reacheble by Internet?
 - Is there some firewall that is blocking IP traffic on your ports?

You should have a public, fixed IP address (not 192.168.x.x, nor 172.16.x.x.-172.20.x.x, nor 10.x.x.x)
You can try to change the server port to a port "Normally left open by firewall" such as 80 (http).
If the problem still persist try netstat command on the server to look at the active connections.

MarcoMi66, you don't actually need a fixed IP address if you use a dynamic name service like or These typically have an application running on your machine which identifies itself to their DNS server so that the name can be resolved, even if you're behind a NAT/firewall router. So, for example, you can register a (free) domain name like "" with DynDNS, and gain TCP access to it just by using the name
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Rohan32Author Commented:
Well it does have betterluck with port 80, it doesn't receive the "connection refused" error but the client is disconnected at once. But I don't understand why the firewall would all of a sudden start blocking ports. I have a software firewall and a hardware one. I have never had to reconfigure the hardware one for games or anything like that, only the software one. Do multiplayer games generally run on ports reserved for that kind of activity or am I still missing something?

And to answer your questions:
 - Has the server a public IP Address? Yes
 - Is the server public IP Address reacheble by Internet? Yes
 - Has the Server some other service reacheble by Internet? Yes (on other ports)
 - Is there some firewall that is blocking IP traffic on your ports? See above
If the firewall(s) have UPnP (Universal Plug and Play) support, they may allow quite a bit of flexibility for outbound connections and for the more common ports (e.g., FTP, SMTP).
sftwengConnect With a Mentor Commented:
Have you considered running a test with the firewall support disabled? You could probably turn off the software firewall for a short test and, depending on the router you're using, step outside the router's firewall - for example, with the LinkSys BEFSR41 router, you can specify a single machine to sit in the "DMZ".
On some firewall you have to "map" the public ip-port to the private ip of the machine on the inside network. It's sometimes called port-forwarding.
If you had a blank screen connecting on port 80, it means that an application running of that IP was listening to port 80. Was it an HTTP server or was it your socket app?

Rohan32, what is the make and model of the router/firewall?
Rohan32Author Commented:
Netgear RT311
Rohan32Author Commented:
Well some kind of manipulation with portforwarding seams to be the way I guess. Will play around a bit with the info on to try to get it to work properly. A thing is though that I want anyone to be able to host without a third computer acting as some kind of master server and without the user having to configure things like port forwarding, but that might not be possible.
Rohan32Author Commented:
I had almost forgotten about this. Well I guess I got an answer that it isn't possible which I will accept as answer. I have split the points based on effort.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.