Beispiel #1
0
        public ClientWindow()
        {
            InitializeComponent();

            // Starts method to read the client configuration from the xml file.
            // Create a xml configuration file if it doenst exist
            ClientFunctions.ClientStartPreparation();

            client = new AsynchronousClient();

            this.StartConnectingToServer();
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     ManualResetEvent[]   connectDoneEvents = new ManualResetEvent[qtdClient];
     ManualResetEvent[]   sendDoneEvents    = new ManualResetEvent[qtdClient];
     ManualResetEvent[]   receiveDoneEvents = new ManualResetEvent[qtdClient];
     AsynchronousClient[] clients           = new AsynchronousClient[qtdClient];
     for (int i = 0; i < qtdClient; i++)
     {
         connectDoneEvents[i] = new ManualResetEvent(false);
         sendDoneEvents[i]    = new ManualResetEvent(false);
         receiveDoneEvents[i] = new ManualResetEvent(false);
         AsynchronousClient c = new AsynchronousClient(i, connectDoneEvents[i], sendDoneEvents[i], receiveDoneEvents[i]);
         clients[i] = c;
         ThreadPool.QueueUserWorkItem(c.StartClient, i);
     }
     Console.WriteLine("Sair");
     Console.ReadKey();
 }
Beispiel #3
0
        static async void StartUDPClient()
        {
            AsynchronousClient socket = new AsynchronousClient();

            socket.StartClient(config.Client.Port, config.Servers[1].Address, config.Servers[1].Port);

            //UDPSocket sock = new UDPSocket();


            //await sock.StartListening(config.Client.Port);
            //await sock.SendTo(config.Servers[1].Address, config.Servers[1].Port, "Hello Server 1, this is the client");


            //new Thread(async () =>
            //{
            //   socket.OpenNat(config.Servers[0].Address, config.Servers[0].Port);
            //});

            //new Thread(async () =>
            //{
            //    socket.OpenNat(config.Servers[1].Address, config.Servers[0].Port);
            //});

            //new Thread(async () =>
            //{
            //    await socket.StartListener(config.Client.Port, config.Servers[0].Address, config.Servers[0].Port);
            //    await socket.StartListener(config.Client.Port, config.Servers[1].Address, config.Servers[1].Port);
            //});


            //Thread.Sleep(5000);

            ////new Thread(() =>
            ////{
            //socket.Send(config.Servers[0].Address, config.Servers[0].Port, "Hello server 1, this is the client");
            //socket.Send(config.Servers[1].Address, config.Servers[1].Port, "Hello server 2, this is the client");

            //Thread.Sleep(5000);



            while (true)
            {
                //new Thread(() =>
                //{
                //    socket.OpenNat(config.Servers[1].Address, newPort);
                //});

                //new Thread(() =>
                //{
                //    socket.OpenNat(config.Servers[1].Address, newPort);
                //});

                //socket.Send(config.Servers[0].Address, newPort, "Hello server 1, this is the client on new port" + newPort);
                //socket.Send(config.Servers[1].Address, newPort, "Hello server 2, this is the client on new port " + newPort);

                Thread.Sleep(5000);
                //new Thread(async () =>
                //{
                //    await socket.StartListener(newPort, config.Servers[0].Address, config.Servers[0].Port);
                //    await socket.StartListener(newPort, config.Servers[1].Address, config.Servers[1].Port);
                //});
            }
        }
Beispiel #4
0
 static void Main(string[] args)
 {
     AsynchronousClient ac = new AsynchronousClient();
 }
Beispiel #5
0
 private void SendButton_Click(object sender, EventArgs e)
 {
     AsynchronousClient.StartClient();
 }