private static void ClientToServer() { _Random = new Random((int)DateTime.Now.Ticks); _DataLargeBytes = InitByteArray(_DataLargeSize, 0x00); _DataLargeMd5 = BytesToHex(Md5(_DataLargeBytes)); _DataSmallBytes = InitByteArray(_DataSmallSize, 0x00); _DataSmallMd5 = BytesToHex(Md5(_DataSmallBytes)); Console.WriteLine("Large Data MD5: " + _DataLargeMd5); Console.WriteLine("Small Data MD5: " + _DataSmallMd5); Console.WriteLine("Starting in 3 seconds..."); _Server = new WatsonTcpServer(null, _ServerPort); _Server.Events.ClientConnected += ServerClientConnected; _Server.Events.ClientDisconnected += ServerClientDisconnected; if (!_UseStreams) { _Server.Events.MessageReceived += ServerMsgReceived; } else { _Server.Events.StreamReceived += ServerStreamReceived; } _Server.Callbacks.SyncRequestReceived = ServerSyncRequestReceived; _Server.Settings.MaxProxiedStreamSize = _MaxProxiedStreamSize; _Server.Settings.Logger = Console.WriteLine; _Server.Settings.DebugMessages = _Debug; _Server.Start(); Thread.Sleep(2000); _Client = new WatsonTcpClient("localhost", _ServerPort); _Client.Events.ServerConnected += ClientServerConnected; _Client.Events.ServerDisconnected += ClientServerDisconnected; if (!_UseStreams) { _Client.Events.MessageReceived += ClientMsgReceived; } else { _Client.Events.StreamReceived += ClientStreamReceived; } _Client.Callbacks.SyncRequestReceived = ClientSyncRequestReceived; _Client.Settings.MaxProxiedStreamSize = _MaxProxiedStreamSize; _Client.Settings.Logger = Console.WriteLine; _Client.Settings.DebugMessages = _Debug; _Client.Start(); Thread.Sleep(2000); Console.WriteLine("Press ENTER to exit"); for (int i = 0; i < _ClientThreads; i++) { Console.WriteLine("Starting client thread " + i); Task.Run(() => ClientTask()); } Console.WriteLine("Press ENTER after completion to view statistics"); Console.ReadLine(); _Client.Stop(); _Server.Stop(); _Server.Dispose(); _Client.Dispose(); Console.WriteLine("Success: " + _Success); Console.WriteLine("Failure: " + _Failure); }