/// <summary> /// Start waiting for incoming packets. /// </summary> public void Start(Socket socket) { if (_socket != null) { ChoTrace.Warn("Already got a socket, disposing it."); Disconnect(); _socket.Close(); _socket = null; } Init(socket); _socket.BeginReceive(_inbuffer, 0, 8, SocketFlags.None, OnReceive, null); }
public void Start() { if (_socket != null) { ChoTrace.Warn("Already got a socket, disconnect first."); return; } _reconnectTimer = new Timer(OnTryToReconnect, null, Timeout.Infinite, Timeout.Infinite); try { Connect(); } catch (Exception ex) { ChoTrace.Debug("Failed to reconnect.", ex); HandleDisconnected(); } }