• Post Reply Bookmark Topic Watch Topic
  • New Topic

Share sockets?  RSS feed

 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a good practice to share sockets if say you will be opening a socket to a machine repeatedly. So instead of creating 10 sockets maybe create one then passing it around?
So I have maybe loop that I call into a method that I open the socket send the message then close. So instead of that I would we would open one socket pass into the method so we share that socket.
Thanks,
Tom
 
Ajay Singh
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its good idea to pool the socket, but you need to make sure that your application know boundaries of request/response correctly.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a good idea to pool any resources that are resource intensive and expensive to create.....

It is like sharing database connections from a pool
[ January 12, 2007: Message edited by: A Kumar ]
 
Sushil Sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharing a common resource can be a problem, specially two or more threads access the socket. Thus, you would have to do some sort of synchronization or mutex.

Pooling is a better idea.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!