[cse491] A few notes on the echo servers
C. Titus Brown
ctb at msu.edu
Mon Sep 28 12:46:47 PDT 2009
On Mon, Sep 28, 2009 at 03:43:36PM -0400, Tim Miller wrote:
> For the non-blocking server, we are supposed to keep track of data
> over multiple receives to keep track of the close connection signal,
> but you specified that the function that handles all sending/receiving
> should take only one argument (the socket) and return true or false.
> So I don't see any room here to pass along connection specific data
> over multiple calls to the handle_connection() function.
>
> The two solutions I can think of are either 1. global variables (eww)
> or 2. passing more information to the function. Is there another way
> to do this?
Good point, and good question.
For now, please just use the (bad) idea of a module-level dictionary
variable where the key is the socket object and the value is whatever
you need to store per-socket.
For future versions of this homework I will specify a way to pass in
more info.
One "proper" way to handle this might be to encapsulate the socket
object in an object that can also contain the other information.
thanks,
--titus
More information about the cse491-fall-2009
mailing list