code: func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (inet.Stream, error) {
  	pref, err := h.preferredProtocol(p, pids)
  	if err != nil {
  		return nil, err
  	}
  
  	if pref != "" {
  		return h.newStream(ctx, p, pref)
  	}
  
  	var protoStrs []string
  	for _, pid := range pids {
  		protoStrs = append(protoStrs, string(pid))
  	}
  
  	s, err := h.Network().NewStream(ctx, p)
  	if err != nil {
  		return nil, err
  	}
  
  	selected, err := msmux.SelectOneOf(protoStrs, s)
  	if err != nil {
  		s.Reset()
  		return nil, err
  	}
  	selpid := protocol.ID(selected)
  	s.SetProtocol(selpid)
  	h.Peerstore().AddProtocols(p, selected)
  
  	return s, nil
  }
docs: // NewStream opens a new stream to given peer p, and writes a p2p/protocol
  // header with given protocol.ID. If there is no connection to p, attempts
  // to create one. If ProtocolID is "", writes no header.
  // (Threadsafe)