def on_close(socket, *data, &block)
      raise UnknownSocket.new(socket) unless @sockets.has_key?(socket)
      raise ArgumentError.new('Block must be supplied') unless block_given?
      raise ArgumentError.new('Block must allow at least one argument') if block.arity == 0
      if(block.arity > 0 && block.arity != (data.size + 1))
        raise ArgumentError.new('Invalid number of arguments for block')
      end
      @sockets[socket][:closed] ||= []
      @sockets[socket][:closed] << [data, block]
    end
def on_close(socket, *data, &block)
      raise UnknownSocket.new(socket) unless @sockets.has_key?(socket)
      raise ArgumentError.new('Block must be supplied') unless block_given?
      raise ArgumentError.new('Block must allow at least one argument') if block.arity == 0
      if(block.arity > 0 && block.arity != (data.size + 1))
        raise ArgumentError.new('Invalid number of arguments for block')
      end
      @sockets[socket][:closed] ||= []
      @sockets[socket][:closed] << [data, block]
    end
socket:: socket to add close action
 data:: data to be passed to the block. NOTE: socket
 will be prepended to argument list
 block:: action to perform on socket close
 Executes block when socket has been closed. Ideal
 for reconnection needs