private bool ProcessCommandArgsAndFile(WriteClient clnt, string[] args) { Console.Write("\n starting CommService client"); Console.Write("\n =============================\n"); clnt.processCommandLine(args); Console.Title = "Write Client #" + clnt.clientCount.ToString(); string localPort = Util.urlPort(clnt.localUrl); string localAddr = Util.urlAddress(clnt.localUrl); clnt.rcvr = new Receiver(localPort, localAddr); if (clnt.rcvr.StartService()) { clnt.rcvr.doService(clnt.defaultServiceAction()); } clnt.sndr = new Sender(clnt.localUrl); Console.Write("\n sender's url is {0}", clnt.localUrl); Console.Write("\n attempting to connect to {0}\n", clnt.remoteUrl); if (!sndr.Connect(clnt.remoteUrl)) { Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); clnt.rcvr.shutDown(); return(false); } return(true); }
//----< Entry point into Write Client >------------------------------ static void Main(string[] args) { WriteClient clnt = new WriteClient(); bool success = clnt.ProcessCommandArgsAndFile(clnt, args); if (!success) { return; } HiResTimer timer = new HiResTimer(); timer.Start(); List <Message> messageList = clnt.ProcessXML("MessagePrototype.xml"); clnt.latencyTimers.Add(new HiResTimer()); clnt.latencyValues.Add(new ulong()); foreach (Message message in messageList) { if (clnt.sndr.sendMessage(message)) { HiResTimer temp = new HiResTimer(); temp.Start(); clnt.latencyTimers.Add(temp); clnt.latencyValues.Add(new ulong()); Console.Write("\n Request ID: {0}\n", message.messageID); Console.WriteLine(message.content); } else { Console.Write("\n could not connect in {0} attempts", clnt.sndr.MaxConnectAttempts); clnt.sndr.shutdown(); clnt.rcvr.shutDown(); return; } } timer.Stop(); Console.WriteLine("\n ====================================================="); Console.WriteLine("\n Total time to send all the messages: {0} microseconds", timer.ElapsedMicroseconds); Console.WriteLine("\n ====================================================="); Message msg = new Message(); msg.fromUrl = clnt.localUrl; msg.toUrl = clnt.remoteUrl; msg.content = "done"; clnt.sndr.sendMessage(msg); while (true) { if (clnt.rcvCount == messageList.Count()) { Thread.Sleep(50); clnt.performanceAnalysis(); break; } } Util.waitForUser(); clnt.rcvr.shutDown(); clnt.sndr.shutdown(); Console.Write("\n\n"); }
//----< Entry point into Write Client >------------------------------ static void Main(string[] args) { WriteClient clnt = new WriteClient(); bool success = clnt.ProcessCommandArgsAndFile(clnt, args); if (!success) return; HiResTimer timer = new HiResTimer(); timer.Start(); List<Message> messageList = clnt.ProcessXML("MessagePrototype.xml"); clnt.latencyTimers.Add(new HiResTimer()); clnt.latencyValues.Add(new ulong()); foreach (Message message in messageList) { if (clnt.sndr.sendMessage(message)) { HiResTimer temp = new HiResTimer(); temp.Start(); clnt.latencyTimers.Add(temp); clnt.latencyValues.Add(new ulong()); Console.Write("\n Request ID: {0}\n", message.messageID); Console.WriteLine(message.content); } else { Console.Write("\n could not connect in {0} attempts", clnt.sndr.MaxConnectAttempts); clnt.sndr.shutdown(); clnt.rcvr.shutDown(); return; } } timer.Stop(); Console.WriteLine("\n ====================================================="); Console.WriteLine("\n Total time to send all the messages: {0} microseconds", timer.ElapsedMicroseconds); Console.WriteLine("\n ====================================================="); Message msg = new Message(); msg.fromUrl = clnt.localUrl; msg.toUrl = clnt.remoteUrl; msg.content = "done"; clnt.sndr.sendMessage(msg); while (true) { if (clnt.rcvCount == messageList.Count()) { Thread.Sleep(50); clnt.performanceAnalysis(); break; } } Util.waitForUser(); clnt.rcvr.shutDown(); clnt.sndr.shutdown(); Console.Write("\n\n"); }
private bool ProcessCommandArgsAndFile(WriteClient clnt, string[] args) { Console.Write("\n starting CommService client"); Console.Write("\n =============================\n"); clnt.processCommandLine(args); Console.Title = "Write Client #" + clnt.clientCount.ToString(); string localPort = Util.urlPort(clnt.localUrl); string localAddr = Util.urlAddress(clnt.localUrl); clnt.rcvr = new Receiver(localPort, localAddr); if (clnt.rcvr.StartService()) { clnt.rcvr.doService(clnt.defaultServiceAction()); } clnt.sndr = new Sender(clnt.localUrl); Console.Write("\n sender's url is {0}", clnt.localUrl); Console.Write("\n attempting to connect to {0}\n", clnt.remoteUrl); if (!sndr.Connect(clnt.remoteUrl)) { Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); clnt.rcvr.shutDown(); return false; } return true; }