Re: Starting New Process



Sorry, I should've specified - I'm familiar with sockets, but I was
referring to spawning a 'vi' process independent of my Python app..


Carl wrote:
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: CLOSE_WAIT state on sockets during high volume
    ... During high volume traffic many of the client sockets are ... > connection after it receives a FIN from the server. ... My server waits for connections, ...
    (comp.unix.programmer)
  • CLOSE_WAIT state on sockets during high volume
    ... During high volume traffic many of the client sockets are ... connection after it receives a FIN from the server. ... My server waits for connections, ...
    (comp.unix.programmer)
  • Re: Server can receive in a socket, but what it sends isnt received in the client.
    ... Do you really have established connection? ... > I have used both synchronous and asynchronous sockets and i'm stuck at ... > connection with the client can't send. ... > UINT HiloCliente(LPVOID pParam) ...
    (microsoft.public.win32.programmer.networks)
  • 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)
  • Re: RMI connection refused... eventually
    ... result in a connection refused exception. ... don't think it is memory related as the server is running with a 1GB heap ... would be hundreds of sockets in the TIME_WAIT state, ... The problem I had was on the client, ...
    (comp.lang.java.programmer)