def establish_association
      # Reset some variables:
      @association = false
      @request_approved = false
      # Initiate the association:
      @link.build_association_request(@presentation_contexts, @user_information)
      @link.start_session(@host_ip, @port)
      @link.transmit
      info = @link.receive_multiple_transmissions.first
      # Interpret the results:
      if info && info[:valid]
        if info[:pdu] == PDU_ASSOCIATION_ACCEPT
          # Values of importance are extracted and put into instance variables:
          @association = true
          @max_pdu_length = info[:max_pdu_length]
          logger.info("Association successfully negotiated with host #{@host_ae} (#{@host_ip}).")
          # Check if all our presentation contexts was accepted by the host:
          process_presentation_context_response(info[:pc])
        else
          logger.error("Association was denied from host #{@host_ae} (#{@host_ip})!")
        end
      end
    end
def establish_association
      # Reset some variables:
      @association = false
      @request_approved = false
      # Initiate the association:
      @link.build_association_request(@presentation_contexts, @user_information)
      @link.start_session(@host_ip, @port)
      @link.transmit
      info = @link.receive_multiple_transmissions.first
      # Interpret the results:
      if info && info[:valid]
        if info[:pdu] == PDU_ASSOCIATION_ACCEPT
          # Values of importance are extracted and put into instance variables:
          @association = true
          @max_pdu_length = info[:max_pdu_length]
          logger.info("Association successfully negotiated with host #{@host_ae} (#{@host_ip}).")
          # Check if all our presentation contexts was accepted by the host:
          process_presentation_context_response(info[:pc])
        else
          logger.error("Association was denied from host #{@host_ae} (#{@host_ip})!")
        end
      end
    end
Opens a TCP session with the server, and handles the association request as well as the response.