     close: () ->
         @conn.end()
         @conn.destroy()
-        
+
 ###
 test = (n=1) ->
     message = require("message")
-    cb = () ->         
+    cb = () ->
         conn.send(message.start_session())
         for i in [1..n]
             conn.send(message.execute_code(id:0,code:"factor(2012)"))

        @recv = options.recv  # send message to client
        @buf = null
        @buf_target_length = -1
        
        @conn.on('error', (err) =>
            winston.error("sage connection error: #{err}")
            @recv?(message.terminate_session(reason:"#{err}"))
        )
        
        @conn.on('data', (data) =>
            # read any new data into buf
            if @buf == null

# code can't be trusted, e.g., anything in the server can be
# arbitrarily modified, all *control* messages, e.g., sending signals,
# cleaning up, etc. absolutely require making a separate TCP connection.
#
# So:
#
#    1. Make a connection to the TCP server, which runs as root and
#       forks on connection.
#
#    2. Create a new session, which drops privileges to a random clean
#       user, and continues to listen on the TCP socket when not doing
#       computations.
#
#    3. Send request-to-exec, etc., messages to the socket in (2)
#       and get back output over (2).
