protected void clearConnectionState() { //Close the socket if it's still open if (tcpClient != null) tcpClient.Close(); if (udpSocket != null) udpSocket.Close(); udpSocket = null; }