Client/Server Question

faulkner faulkner612 at comcast.net
Fri Jul 28 18:06:00 EDT 2006


you might want to look at sshd. if you're on a windows box, you may
need cygwin. if you're on linux, you either already have it, or it's in
your package manager.

diffuser78 at gmail.com wrote:
> My server.py looks like this
>
> ---------------------------------------------CODE----------------------------------
> #!/usr/bin/env python
> import socket
> import sys
> import os
>
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> host = ''
> port = 2000
>
> s.bind((host,port))
> s.listen(1)
> conn, addr = s.accept()
> print 'client is at', addr
>
> while True:
> 	data = conn.recv(1000000)
> 	if (data == 'MaxSim'):
> 		print 'MaxiSim'
> 		os.system('notepad')
> 	elif (data == 'Driving Sim'):
> 		print 'Driving Sim'
> 		os.system('explorer')
> 	elif (data == 'SHUTDOWN'):
> 		print 'Shutting down...'
> 		os.system('shutdown -s')
> 		conn.close()
> 		break
> -------------------------------------------CODE
> END-------------------------------------
>
> I am running this above program on a windows machine. My client is a
> Linux box. What I want to achieve is that server.py should follows
> instructions till I send a 'SHUTDOWN' command upon which it should shut
> down.
>
> When I run this program and suppose send 'MaxSim' to it, it launches
> notepad.exe fine, but then after that it doesn't accept subsequent
> command. I want is that it should accept subsequent commands like
> Driving Sim and launch windows explorer etc untill I send a 'SHUTDOWN'
> command.
> 
> Any help on this, it will be greatly appreciated.




More information about the Python-list mailing list