public void ConnectCommunicator() { if (AuthCommunicator?.Connected ?? false) { AuthCommunicator?.Close(); } try { AuthCommunicator = new LengthedSocket(SizeType.Word); AuthCommunicator.OnConnect += OnCommunicatorConnect; AuthCommunicator.ConnectAsync(new IPEndPoint(IPAddress.Parse(Config.CommunicatorConfig.Address), Config.CommunicatorConfig.Port)); } catch (Exception e) { Logger.WriteLog(LogType.Error, "Unable to create or start listening on the client socket! Retrying soon... Exception:"); Logger.WriteLog(LogType.Error, e); } Logger.WriteLog(LogType.Network, $"*** Connecting to auth server! Address: {Config.CommunicatorConfig.Address}:{Config.CommunicatorConfig.Port}"); }