Network programming


I have a Chess Game that use Remote PC IP to connect to that PC and than two PC user can play Chess game, on network. It works fine until I discover one problem.
That when a Server runs behind the NAT router the connection never established.

Can anyone give me idea about how can I make sure that IF a IP is running My Game server one machine and a Remote client how can access taht IP can establish the connection.

I agree taht if a person has firewall to block data, but it should be the case here. Also I see some good softwares doesn't have such problem. and they can transfer data and establish connection successfully.

I am using Vb.NEt as programming language and I Got 10061 Connection refused error when ever I got such problem.

I read some article on internet suggesting that NAT router drop packets that doesn't use standard ports and are not configured in there routing table.

Anyone Please help on this... even a allien language code will do the job for me..

Who is Participating?

House hold routers will not allow ANY port forwarding, even port 80, as it is unusual for a home user to host a website from behind their router.  MSN messenger had this very issue.  Chat works great with MSN, well that's because you connect to a server that relays all of your communications.  But when you tried to voice chat over older versions of MSN (i think the absolute latest fixed this) you had to enable port forwarding on the router.  That's because for voice chat (and now i recall early file transfers worked this way as well), you needed to connect directly to the other MSN client.

This of course has it's own security issues to deal with, as people were able to get the IP address of the person they were talking with.  Now microsoft is starting to relay voice chat and file transfers through their servers to avoid having to enable port forwarding.

Games like World of Warcraft (WOW), Dark Age of Camelot, etc. all run without port forwarding as the users connect to a server to play the game.  Of course, with WOW the patch updater uses torrent technology which requires that clients directly connect to other clients to help download the patch.

Really, the only thing that moving to port 80 will do for you, is allow you to bypass corporate firewalls.  

Solution would be for you to put your own server on the internet that will handle and relay all of the games being played.

Oh and if you decide to run your service on a port that a pre-existing service already runs on.  Learn the protocol (in this case HTTP) and make sure your game can handle and drop all known protocol commands to avoid your came from crashing.  And when you handle the messages, make sure you return the proper protocol return message to the end user.  For info on the HTTP protocol just google "HTTP Protocol".

Considering everything, i'd suggest your own server, and your own port ;)  Bypassing corporate firewalls isn't worth the coding trouble, because you'd have to add some protocol handling.
Dont know if this is possible, can u use a specific port when talking to a remote PC?
Then in the firewall settings, u can use Port Forwarding, basically enable that port for access

ensure the port that u use, no one else is using it

Does this particular computer u talk to, one behind a firewall. If firewall disconnected, can u still connect? This is only to verify you are using the right connection details.

VIkasumitAuthor Commented:

Well I am using a define port only, and I am not talking about firewall.

Actually NAT Router device, that are most commonly used tend to drop packets if they are not configured to forward them.

And Currently I have to make each one to configure their router to do so....
But this is not Good for me and I want that they need not to set the port forwarding...

And yes if you have "Clear" network between two pc my game will always connect.


Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

In this environment who is the "server" and who is the "client"?  Does it depend on who starts the game?

Basically whoever is going to act like the "server" (accept the established TCP/IP connection, accept input from the client and send output back to the client) will have to configure their router for port forwarding.  The "client" will only be sending data, so you do not need port forwarding on their firewall.

All port forwarding does is it watches for a communication to come in on the WAN side of the router and then forward that communication back to the provided IP address in the port forwarding table.

For clients they are not accepting the incomming connection, so they do not need port forwarding.  Think of it as if they are only sending data out from the LAN side of the router.  The connection was already established with the server.  It's like serving web pages.  You can host a website on any port you want (will within reason of course) and the client will never have to configure their router to connect.
VIkasumitAuthor Commented:

Yes it depends on how starts the game..

Second point I agree :)

I agree waht you said, I need a solution to bypass this condition so that even server doesn't need to set portforwarding..

I have few thinks in mind for this,like Sending my data using port 80, but than it shouldn't collide with Webserver and things like that.. any idea on this.

VIkasumitAuthor Commented:

Thanks for your idea, I like your suggestion of setting my own game server, Though this is seperate question altogether, I will ask it once I decide on pricing thing on this :o)

For now, I got my solution, But I think its hard to implement as no shared hosting company provide you to set and run windows application, :o(

I have to think of making so other Way for my online game project..

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.