Campbell Ritchie wrote:Welcome to the Ranch
Thank you
Campbell Ritchie wrote:
I think you have misunderstood the purpose of the main method It is there to start an application. Ideally it should contain one line. So your application main method would create an object, and call a method on that, which starts everything else running.At your stage you would run everything else on the same console, so you would not usually require several consoles.
Please explain more.
Sure, I'll explain more. So, I have to do Boss{} and Servants{} both with the main because what I am doing is a project for uni, and my professor
absolutely wants those objects istantiated separately.
The situation Boss{main()} and Servants{main()} is required by default.
Boss{main()} has to be run once
Servants{main()} has to be run a fixed number of times.
In the following there is what is it done by both main in short:
BOSS
ps. the object Peer is an object that is the "base model" of the Boss and Servants, things done in common.
SERVANT
Originally I did the project with only one main, but the professor told me to change things in order to have the Boss and Servant with their own main, because he wants everything to be differently istantiated.
So what I did is the following: I have separated the main in two as you can see above. Then, I run the Boss, and the Servants the number of times required with the green button of eclipse, paying attention to pin the console and select a new console each time. In the Servant object I added also a line that allowed me to type the ]index. It worked and everyone has it own console. But this way it is really cumbersome.
Now, what I am trying to do is the following:
(?)_make a nice and simple start-up, where I can set up the number of servants, give the id and the listening port to the Servants and make everybody knows each other references (host, port) because everyone comunicates with everybody by UDP socket;
WELLKNOWN =7000 is the port if the Boss; so every port of the servants is like 7001, 7002, 7003...blablabla, and the respective index is 0(Boss),1, 2, 3...blablabla.
This for loop is in the object Peer.
(?)_If the batch script can be a solution, how can I write it?
(?)_ Any idea is very very wellcome
Thank you and sorry if my post is wordy.
maribo