code: func (l *listenContext) createEndpointAndPerformHandshake(s *segment, opts *header.TCPSynOptions) (*endpoint, *tcpip.Error) {
  	// Create new endpoint.
  	irs := s.sequenceNumber
  	cookie := l.createCookie(s.id, irs, encodeMSS(opts.MSS))
  	ep, err := l.createConnectedEndpoint(s, cookie, irs, opts)
  	if err != nil {
  		return nil, err
  	}
  
  	// Perform the 3-way handshake.
  	h := newHandshake(ep, l.rcvWnd)
  
  	h.resetToSynRcvd(cookie, irs, opts)
  	if err := h.execute(); err != nil {
  		ep.Close()
  		return nil, err
  	}
  
  	// Update the receive window scaling. We can't do it before the
  	// handshake because it's possible that the peer doesn't support window
  	// scaling.
  	ep.rcv.rcvWndScale = h.effectiveRcvWndScale()
  
  	return ep, nil
  }
docs: // createEndpoint creates a new endpoint in connected state and then performs
  // the TCP 3-way handshake.