- Home /
Question by
iamthecoolguy11 · May 17, 2020 at 08:23 PM ·
c#crashingsockets
Built game crashes when I run Socket.Close(), works fine in editor tho
I built a multiplayer game and it works fine in the editor for disconnecting and reconnecting, but in the build it crashes every time I try to disconnect. Im using unity 5.4.1f1
Here's the disconnect code
public void Disconnect()
{
if(m_Connected == true)
{
// Close down the connection
if (this.networkStream != null)
this.networkStream.Close();
if (this.tcpClient != null)
this.tcpClient.Close();
if (this.clientSocket != null)
this.clientSocket.Close();
// Clean up the connection state
this.networkStream = null;
this.tcpClient = null;
this.clientSocket = null;
this.m_Connected = false;
}
}
Comment
Answer by AlirezaSH2004 · May 17, 2020 at 09:11 PM
Hello there. Have you tried to firstly close the socket and then the TCP client?