Re: Starting New Process



D wrote:

Thanks, Jean-Paul - is there any way to do it without using Twisted,
since I am not very familiar with it? (i.e. just using the os library)
Thanks.

Jean-Paul Calderone wrote:
On 1 Jun 2006 07:34:23 -0700, D <duncanm255@xxxxxxxxxxx> wrote:
Hello, I need to write a server program that performs the following
tasks:

1) Listens on TCP port 5555 for a connection
2) When client connects, launches application (for example, vi), then
closes connection with client
3) Goes back to listening on TCP port 5555 for an incoming connection

Untested:

from twisted.internet import protocol, reactor

class ViRunner(protocol.Protocol):
def connectionMade(self):
reactor.spawnProcess(
None,
'/usr/bin/setsid',
['setsid', '/usr/bin/vi'])
self.transport.loseConnection()

f = protocol.ServerFactory()
f.protocol = ViRunner
reactor.listenTCP(5555, f)
reactor.run()

Jean-Paul

Use import socket ifyou don't want to use twisted (which is incredibly
good). Google for "+socket +python +server" and you will find what you are
looking for.

See, for example,
http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/wireless/5.html

Carl
.



Relevant Pages

  • Re: Sockets
    ... I'll have a server application that will listen on a tcp port and make ... share the socket connection across the two threads? ... accepting client connections, thread 2 will we writing data to it.) ... def connectionMade: ...
    (comp.lang.python)
  • Failure Sending a Fault: System.Net.Sockets.SocketException
    ... I have a service and client that use WSE 2.0 and soap.tcp. ... Client connects to a public machine's tcp port which is ... If I send a request to service, it is received, but I can't get the ... Failure Sending a Fault: System.Net.Sockets.SocketException: A connection ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: RWW not working on some client desktops
    ... On a SBS-based computer, the Remote ... > Web Workplace uses TCP port 4125 for its remote desktop feature. ... > remote computer's connection request. ... > problematic client workstations? ...
    (microsoft.public.windows.server.sbs)
  • Re: Help on socket lib and TCP/IP handshake
    ... Linux) and another client like component.Server ... listens to a particular port.Windows component does the initial ... descriptor limit exceeded) or ENFILE (system descriptor limit ... exceeded) or a file descriptor etc for the new connection will have ...
    (comp.os.linux.development.apps)
  • Re: Starting New Process
    ... Sorry, I should've specified - I'm familiar with sockets, but I was ... When client connects, launches application, then ... closes connection with client ... Goes back to listening on TCP port ...
    (comp.lang.python)