Archived

This topic is now archived and is closed to further replies.

guest789

strange connect() problem

Recommended Posts

Hi... I''ve written a small networking arcade game and it works fine locally (127.0.0.1) and via lan... but when somebody tries to connect to a remote server of the game via internet the connect() returns "connection refused" and shuts down the game client... That''s quite strange... never saw that before... There are no firewall rules, proxies, etc set on both sides of the conection but it still refuses to connect... I''ve written some small tests just to check whether it is possible to connect at all... theses small programs interact perfectly... There''s no problem with the code of the game... It runs fine in lan space (via TCP/IP)... But it goes down with internet... Please help... What''s the problem with it?

Share this post


Link to post
Share on other sites
If you are binding the *server* to 127.0.0.1 it will be unable to receive client connections from the internet (or any other computer for that matter.) You need to bind the server to your IP address *or* just using INADDR_ANY. That will allow your clients to connect to your server.


Share this post


Link to post
Share on other sites
I always bind server to INADDR_ANY. And on the client side i'm setting 127.0.0.1 for local testing... But when i try to test via internet i change that IP to match the real IP of the server in the internet address space... I wouldn't be able to test it in lan (client on one computer and server on another, both on lan) if i binded server to 127.0.0.1...
So, binding to a wrong address is not a problem here...

[edited by - guest789 on May 29, 2003 9:14:41 AM]

Share this post


Link to post
Share on other sites
Can you ping that address from your machine? Sometimes, ISPs set up firewalls to block incoming traffic except on specific ports.

Share this post


Link to post
Share on other sites
"There are no firewall rules, proxies, etc set on both sides of the conection but it still refuses to connect...
I''ve written some small tests just to check whether it is possible to connect at all... theses small programs interact perfectly..."... I can ping the remote computer (server) + i can eveb establish a TCP connection with it (with one of my test programs)... but the game client is not able to connect to it... :\ Thats strange.... It connects perfectly via lan... But it doesn''t interact via internet...

Share this post


Link to post
Share on other sites