Network programming

Posted on 2006-05-10
Last Modified: 2012-06-21

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..

Question by:VIkasumit
    LVL 65

    Expert Comment

    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.

    LVL 4

    Author Comment


    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.


    LVL 2

    Expert Comment

    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.
    LVL 4

    Author Comment


    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.

    LVL 2

    Accepted Solution


    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.
    LVL 4

    Author Comment


    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..


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now