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 126.96.36.199 at say port 5555.
- Server gets request through the routers that are forward.
- -Server now has the IP that sent the request? 188.8.131.52. and wants to send it's reply here.
- Server sends reply to Client IP 184.108.40.206: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.