added all connect/handshake functionality