I need to open multiple socket connection to different IPs, which I will be doing it in a 'for' loop. Is it a best practice to create a new Socket object within the for loop? Or is it fine if I create a new Socket object before the for loop, use it for multiple connections and subsequently close it after the for loop.
Thanks.
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
How would you go about changing the host/IP a socket is connected to after it has been created?
I need to open multiple socket connection to different IPs, which I will be doing it in a 'for' loop. Is it a best practice to create a new Socket object within the for loop? Or is it fine if I create a new Socket object before the for loop, use it for multiple connections and subsequently close it after the for loop.
Thanks.
You cannot use a Socket for multiple connections.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.