title: "tcp session control protocol" in linux kernel?
body: <p>I'm programming in Linux environment.</p>
  
  <p>I want to establish a TCP socket between two PCs, and multiplexing it.</p>
  
  <p>To be specific, here is the pseudo-code:</p>
  
  <pre><code>void func_in_process0()
  {
      socket s = socket(AF_INET, SOCK_STREAM, 0);
      connect(s, "1.1.1.1", 8080);
  
      socket s1 = ADD_CHANNEL(s, 1);                    // key part
      SEND_FILE_DESCRIPTOR_TO_PROCESS(s1, process1);
      socket s2 = ADD_CHANNEL(s, 2);                    // key part
      SEND_FILE_DESCRIPTOR_TO_PROCESS(s2, process2);
  
      WAIT_FOR_PROCESS_TO_FINISH(process1);
      WAIT_FOR_PROCESS_TO_FINISH(process2);
  
      close(s);
  }
  
  void func_in_process1()
  {
      socket s1 = GET_SOCKET_FROM_PROCESS0();
  
      send(s1, "abcdefg");
      close(s1);
  }
  
  void func_in_process2()
  {
      socket s2 = GET_SOCKET_FROM_PROCESS0();
  
      send(s2, "abcdefg");
      close(s2);
  }
  </code></pre>
  
  <p>The key part is how to implement function ADD_CHANNEL.</p>
  
  <p>I found a document <a href="http://www.w3.org/Protocols/HTTP-NG/http-ng-scp.html" rel="nofollow">TCP Session Control Protocol</a> which provides exactly the function I want.
  But I don't think it is implemented in Linux kernel.</p>
  
  <p>I can implement this protocol in userspace, but variable "s1" and "s2" will not be file descriptor and can't be sent to other processses.</p>
  
  <p>Edit:</p>
  
  <ol>
  <li><p>process0, process1 and process2 are all on localhost.</p></li>
  <li><p>socket "s" is a client socket.</p></li>
  <li><p>1.1.1.1 is a remote PC, who is the server. so proc1 and proc2 both sends packet to 1.1.1.1 through the CHANNEL.</p></li>
  <li><p>the server is CHANNEL aware too.</p></li>
  </ol>
  
  <p>Edit2:</p>
  
  <ol>
  <li><p>I read the <a href="http://www.ibiblio.org/ses/scp.html" rel="nofollow">SCP Protocol</a>, but it still has no in-kernel implementation.</p></li>
  <li><p>I learned the SCTP multi-streaming, which is implemented in kernel, but there's no API that creates sub-socket so the problem remains.</p></li>
  </ol>