Approaches for having multiple applications receive data via port 80

98 views Asked by At

I'm looking for suggestions about approaches to allow multiple applications to use port 80 for communication.

I know it's impossible, or at lease not sensible to have multiple applications to actually bind to port 80, however, I've seen appliances when there is a device that provides both a web interface (HTTP) and RTSP with RTP using port 80.

I have two ideas on how this is achieved:

Are those custom made apps that implement all the functions?

For example the same binary is used for a web server and a RTSP server. That seems kind of limiting due to the fact that you would have to do sever modifications to already developed apps if you want, for example, Apache and openSSH both on port 80.

Are there a "port 80 multiplexers" sort of a pattern?

For example, a parser application that listens to port 80 and depending on the header of the received package, passes the package to the required application.

Found some related references, will give them a try.

1

There are 1 answers

0
rodolk On

I really don't think this is possible in a standard way: port number is actually the one that allows multiplexing among different applications in TCP and UDP protocols. More generic, TSAP, Transport Service Access Point allows multiplexing at the transport layer. TSAP is the port in protocols such as TCP, UDP, or SCTP.

One reason you may want two applications listening on the same port is that a second application can monitor or process in some other way the messages received, and eventually processed, by the first one. In this case, using pcap library other applications could read messages received by the main application that will probably response those messages.

Netfilter can also be useful, http://www.netfilter.org/

However, if you intend two applications to respond messages that arrive to the same port, that would be tricky and would have dependency on each application.

In this response I'm assuming you are thinking of applications listening to the same port at the same IP address. Something different is working with multihost servers where two applications could listen to same port number in different IP addresses.