Exemple #1
0
        private void AskForJobs()
        {
            JobAction receivedAction = null;

            Sender.Connect(RemoteEp);

            do
            {
                var bytes = new byte[100000];
                try
                {
                    Sender.Receive(bytes);
                    receivedAction = (JobAction)SocketHelper.Deserialize(bytes);

                    if (!receivedAction.NoJobsLeft)
                    {
                        Console.WriteLine("I got a job");
                        receivedAction.Run();

                        Sender.Send(SocketHelper.Serialize(receivedAction));
                    }
                }
                catch (SocketException e)
                {
                    Console.WriteLine(e);
                    Sender.Shutdown(SocketShutdown.Both);
                    Sender.Close();
                }
            } while (receivedAction != null && !receivedAction.NoJobsLeft);
        }