Version: 2019.4
LanguageEnglish
  • C#
Method group is Obsolete

NetworkTransport.GetEncryptionSafeMaxPacketSize

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete The UNET transport will be removed in the future as soon a replacement is ready.

Declaration

public static short GetEncryptionSafeMaxPacketSize(short maxPacketSize);

Parameters

maxPacketSize The largest packet size that the network allows, in bytes.

Returns

short The maximum amount of bytes that can you can safely send over the network so they fit in the given maximum packet size after encryption.

Description

Gets the safe un-encrypted maximum payload size for a given maximum packet size.

Use this function to get the maximum amount of un-encrypted bytes you can send over the network so that they fit into a given maximum network packet size after encryption. This function calls the provided encryption plugin loaded through NetworkTransport.LoadEncryptionPlugin to get the safe size, because the size depends on the padding and extra header information that the encryption algorithm adds to the data.