socketServer questions

Paul Rubin http
Fri Oct 7 12:17:53 EDT 2005


rbt <rbt at athop1.ath.vt.edu> writes:
> 1. Do I need to use threads to handle requests, if so, how would I
> incorporate them?  The clients are light and fast never sending more
> than 270 bytes of data and never connecting for more than 10 seconds
> at a time. There are currently 500 clients and potentially there
> could be a few thousand... how high does the current version scale?

The way it's written now, the server reads a single request, writes
some stuff to the log, and closes the connection.  It can't handle
multiple requests simultaneously, but that's ok, no connection stays
open for very long.  If you want to have longer-running connections
open simultaneously, you need some type of concurrency such as threads.
But then you have to write the code differently, to serialize the
log recording.  

You probably should get a copy of "Python Cookbook" which explains the
basics of multi-threaded programming, if you have to ask a question
> like that.

> 2. What's the proper way to handle server exceptions (server stops,
> fails to run at boot, etc.)?

> 3. How do I keep people from tampering with the server? The clients
> send strings of data to the server. All the strings start with x and
> end with y and have z in the middle. Is requiring x at the front and
> y at the back and z someplace in the middle enough to keep people
> out? I'm open to suggestions.

It only keeps them out if they don't know to use that x..y..z pattern
and maybe not even then.  Get a copy of "Security Engineering" by
Ross Anderson to have an idea of what you're dealing with, especially
if your server controls something valuable.



More information about the Python-list mailing list