public void ConnectAsync(OnClientConnectedCallback callback) { if (socket.Connected) { if (callback != null) { callback(); } } else { socket.BeginConnect( this.Endpoint.CreateIpEndpoint(), (ia) => { socket.EndConnect(ia); if (callback != null) { callback(); } }, null); } }