1

I want to immplement a Mesh network(each peer can be client and also server) based on UDP and broadcast in Java. I am working on my local system and try to run multiple instance from one class. But I want to know is there any possibilies in java to run multiple console inside of the code and assign a port to each consol/terminal when they are runnig as a peer in the network?

I mean I want to run multiple consols by Java code and assign a port number to each one for communicating.

I have 2 arraylists to define the port numbers for sending and receiving.

Thanks for your help

  • My reaction is "why?". First assumption - that you're running separate instances (separate JVMs, separate processes) since otherwise there's little point in using UDP multicast in a single address space. Therefore, why not start each instance in a separate terminal to begin with? – user16632363 Nov 21 '21 at 19:27
  • Thanks for your reply, because I dont know when I run a new instance, how can I connect it to the network to start the communication. That is why I wanted to control it inside the code. – venus kiani Nov 22 '21 at 08:07
  • Conventionally, clients connect to servers. Each client instance knows when it's been started because... it's been started. The client assigns itself an unused port. The server knows about the client and the client's port because the client connects to the server. (I use "connect" loosely here, it's UDP. "Communicates with" is more accurate). – user16632363 Nov 22 '21 at 12:54
  • sorry but its Mesh network and I should not have any server to control the netwotk. This is my problemm, because I dont know without server how can I manage peers??!! – venus kiani Nov 22 '21 at 16:44

0 Answers0