Thread: No port forwarding, question.

  1. #1
    Registered User
    Join Date
    Dec 2010
    Location
    Belfair
    Posts
    1

    Smile No port forwarding, question.

    I am attempting to make a simple chat program, chat room type thing. I've already made an online version of the program, running with javascript, php, mysql. I will now be writing another version of the program that will access the mysql database except it will be writin in C++ and will have to use it's own port.
    My problem is that I plan on writing two separate programs, Server and Client and I've run into one question.
    When I write the program how to I make it so that I do not have to have the Client forward there port. In other words, how to I write the program in such a way that only the Server needs to. So that anyone who is behind a router or other device, the Server is able to send its replies directly to the Client.

    I do not necessarily need any code, though if it helps your explination be my guest. What I really need is the concept of how the information should be sent or recieved.
    I may in fact be looking at this all wrong and assuming the wrong things when it comes to the transfer of the data, but I am rather new to C programing and only have a very little knowledge. I am able understand a good amount of the code, I'm just slow starter when it comes to writing my own.

    To help you understand what I am thinking when I ask you this, so that you can correct me.
    This is my assumtion of how the data is sent.
    • Client sends request to Server IP 111.111.111.111 at say port 5555.
    • Server gets request through the routers that are forward.
    • -Server now has the IP that sent the request? 222.222.222.222. and wants to send it's reply here.
    • Server sends reply to Client IP 222.222.222.222:5555
    • If port is not forwarded, Client would not recieve reply through router.


    As I am writing this I am thinking about the method by which my web chat works. Client with AJAX pings server continuosly and to pretty much say "I'm here, what you got" and with the page load the server sends its reply.

    Though I am also considering that maybe my question is answered somewhat by that.
    Do I keep my connection open while sending the request? how so?
    Is there a simpler method?

    Thank you for your help.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by TJMaster View Post
    When I write the program how to I make it so that I do not have to have the Client forward there port. In other words, how to I write the program in such a way that only the Server needs to. So that anyone who is behind a router or other device, the Server is able to send its replies directly to the Client.
    If your client connects out to the server via TCP there shouldn't be a problem.

    Another method is for the client to use UPNP to initiate a temporary port forward on the router...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question on Accessing parallel port
    By Luciferek in forum C++ Programming
    Replies: 6
    Last Post: 06-16-2008, 05:36 PM
  2. multiplexing
    By kaijuu in forum C Programming
    Replies: 0
    Last Post: 03-29-2008, 06:47 AM
  3. Problem with string and serial port
    By collinm in forum C Programming
    Replies: 2
    Last Post: 03-23-2005, 10:19 AM
  4. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM

Tags for this Thread