• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple Socket connection

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would you go about changing the host/IP a socket is connected to after it has been created?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binesh Veetil wrote:Hi,

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic