I have a page that already makes multiple AJAX requests at the same time. They use the Comet model, so there are always multiple HTTP connections open, waiting for more data from the server. As the page gets more complex in the future there may be even more. I'm concerned about opening too many connections.
I wonder if there is a way to "multiplex" them, ie. have a single connection through which all requests are sent and route the messages to the appropriate handler functions on both the server and the client sides.
So far I can't figure out a way to do this, because once I make an HTTP request and it begins waiting for data I don't think it's possible to send more request data. I could close that connection before opening another one to send more data, but what if the server sends a response just then?
Am I trying to do something I shouldn't?