 #### Connection Listener (socket events handler)
 # This is modelled after Node.js' http.js
 
-connectionListener= (socket) ->
+connectionListener= (socket,intercept_response) ->
+
+  new_response = ->
+    res = new eslResponse socket
+    if intercept_response?
+      res.intercept_response = intercept_response
+
   socket.setEncoding('ascii')
   parser = new eslParser socket
   socket.on 'data', (data) ->  parser.on_data(data)

              req.channel_data = channel_data
              req.unique_id = unique_id
              server.emit 'CONNECT', req, res

      if exports.debug
        util.log util.inspect command: command, args: args

      if cb?
        @intercept_reponse command, args, cb

      # Send the command out.
      @socket.write "#{command}\n"
