title: Twisted - listen to multiple ports for multiple processes with one reactor
body: <p>i need to run multiple instances of my server app each on it's own port. It's not a problem if i start these with os.system or subprocess.Popen, but i'd like to have some process communication with multiprocessing. </p>
  
  <p>I'd like to somehow dynamically set up listening to different port from different processes. Just calling reactor.listenTCP doesn't do it, because i getting strange Errno 22 while stopping reactor. I'm also pretty sure it's not the correct way to do it. I looked for examples, but couldn't find anything. Any help is appreciated. </p>
  
  <p>EDIT:
  Thanks Tzury, it's kinda what i'd like to get. But i have to dynamicly add ports to listen. For Example </p>
  
  <pre><code>from twisted.internet import reactor 
  from multiprocessing import Process 
  
  def addListener(self, port, site): 
      ''' Called when I have to add new port to listen to. 
      site - factory handling input, NevowSite in my case''' 
      p = Process(target=f, args=(port, func)) 
      p.start() 
  
  def f(self, port, func): 
      ''' Runs as a new process''' 
      reactor.listenTCP(port, func)
  </code></pre>
  
  <p>I need a way to neatly stop such processes. Just calling reactor.stop() stop a child process doesn't do it.</p>
  
  <p>This is the error i'm gettin when i trying to stop a process</p>
  
  <pre><code>    --- &lt;exception caught here&gt; ---
    File "/usr/share/exe/twisted/internet/tcp.py", line 755, in doRead
      skt, addr = self.socket.accept()
    File "/usr/lib/python2.6/socket.py", line 195, in accept
      sock, addr = self._sock.accept()
  &lt;class 'socket.error'&gt;: [Errno 22] Invalid argument
  </code></pre>
  
  <p>Dimitri.</p>