Reputation: 496
I am creating a server application for fun & knowlege in C (no classes please as I don't understand them yet). The purpose of this application is to listen on a specified port, lets say 8118 When connecting to the server there will be a login in which after I would like to forward the connection to a administrative console. The administrative console port will be listening locally, meaning it wont be port forwarded on the router. Lets define this port as 5115.
So it would look like this
Client -> Server:8118 -> ServerRedirect to local 5115
The purpose of this is I will eventually be forwarding to multiple local ports depending on the command post-login.
Is there a efficient way of doing this? Also are there any issues I might come across that I should look out for?
Thanks in advance.
Upvotes: 1
Views: 59
Reputation: 284
Not sure of your setup, but there are basically two choices:
Bounce a message back to the client telling it 'go check port 5115'. Whether this works depends on the client; a http redirect will work if the client is a web browser.
Open an internal connection to port 5115 and then your program will site there transferring data between the client (which remains attached to port 8118) and port 5115.
Also, why do you need to do this? If you just want to avoid blocking port 8118, just set SO_REUSEADDR on the listening port.
Upvotes: 1