ngtcp2_pkt_write_connection_close ================================= Synopsis -------- *#include * .. function:: ngtcp2_ssize ngtcp2_pkt_write_connection_close( uint8_t *dest, size_t destlen, uint32_t version, const ngtcp2_cid *dcid, const ngtcp2_cid *scid, uint64_t error_code, const uint8_t *reason, size_t reasonlen, ngtcp2_encrypt encrypt, const ngtcp2_crypto_aead *aead, const ngtcp2_crypto_aead_ctx *aead_ctx, const uint8_t *iv, ngtcp2_hp_mask hp_mask, const ngtcp2_crypto_cipher *hp, const ngtcp2_crypto_cipher_ctx *hp_ctx) `ngtcp2_pkt_write_connection_close` writes Initial packet containing CONNECTION_CLOSE frame with the given *error_code* and the optional *reason* of length *reasonlen* to the buffer pointed by *dest* of length *destlen*. All encryption parameters are for Initial packet encryption. The packet number is always 0. The primary use case of this function is for server to send CONNECTION_CLOSE frame in Initial packet to close connection without committing any state when validating Retry token fails. This function returns the number of bytes written if it succeeds, or one of the following negative error codes: :macro:`NGTCP2_ERR_NOBUF` Buffer is too small. :macro:`NGTCP2_ERR_CALLBACK_FAILURE` Callback function failed.