# File alienconnection.rb, line 31
        def receive(opts={})
                timeout = opts.fetch(:timeout, 40).to_i
                wait_for_null = opts.fetch(:wait_for_null, true)
                
                response = ""
                
                # Wait for data to become available on the socket
                res = select([@sock], nil, nil, timeout)
                if (res == nil)
                        raise "Timeout waiting for reader response." if @raise_errors
                end
                
                if (wait_for_null)
                        begin
                                timeout(timeout) {
                                        response = @sock.gets("\0")
                                }
                        rescue Timeout::Error
                                raise "Timeout waiting for reader response." if @raise_errors
                        end
                        
                        response.strip!
                        
                        if response.include? "Error"
                                raise response if @raise_errors
                        end
                        
                        # If this is a response to a Quit command, the reader will close the socket. 
                        # If there is an active connection, the reader will reject our attempt to connect.
                        # Either way, we're not connected anymore...
                        if (response.include? "Goodbye!")
                                close(false)
                        end
                        
                        return response
                else
                        # Simply try to read up to 1 kB and return it (no timeout)
                        return @sock.recv(1024)
                end
        end