title: How to make apache process TCP connections?
body: <p>I have a problem that is stuck in my mind for almost 24 hours, and at this moment I don't know how to fix it.</p>
  
  <p>Here is the thing: I want to have one 'main' socket on my server that processes all incoming data and sends it to other clients using PHP. That part goes fine, but I want to connect with that socket using multiple subdomains, e.g. ex.example.com. The thing with this is, that you cannot connect with that subdomain unless you have a socket running on it, and that just fills up your ports and that is what I'm trying to prevent. </p>
  
  <p>The best solution is to make Apache process the incoming TCP request, saves the data on which domain you are connecting, and then redirects the client to the main socket, which processes the received data and immediately acts when the client is accepted.</p>
  
  <p>Honestly, I have no idea how to do this. I'm searching for hours, but the only thing I've found was something on Stackoverflow that got close to it: <a href="https://stackoverflow.com/questions/3917167/apache-handling-tcp-connections-but-not-http-requests">Apache - handling TCP connections, but not HTTP requests</a></p>
  
  <p>But with that piece of script I am not able to save data (which domain you're using) and send it to the main socket.</p>
  
  <p>I don't know if this can be done by Apache or if it is possible at all, or if there are any other workarounds. </p>
  
  <p>Thank you :)</p>