Version: 2022.3
LanguageEnglish
  • C#
Removed

Network.Disconnect

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 legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.

Declaration

public static void Disconnect();
Obsolete The legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.

Declaration

public static void Disconnect(int timeout);

Description

Close all open connections and shuts down the network interface.

The timeout parameter indicates how much time in milliseconds the network interface gets to signal to others that it is disconnecting. The network state, like security and password, is also reset.

Note that if you set the timeout to 0 the network interface will shut down before the disconnect notification can be sent to the remote party. For a client this could mean they cannot reconnect to the server as the server thinks they are still connected (after a certain interval the connection will be detected as dropped).