File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Socket connection performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket connection performance" Watch "Socket connection performance" New topic

Socket connection performance

Harish Tiruvile
Ranch Hand

Joined: Dec 01, 2005
Posts: 99

While writing one simple chat application i got one doubt .
Suppose ,if i am chatting with single person ,i will establish socket connection with that client and send message to that client to particular port.Once i finsh chat i will close socket connection.

Now if i want to chat with more people say 100 people(just an example) at a time .then is it good to create 100 different socket connection?

Where as in database we normally use Connection pool,so i can reuse already created object.Do we have same think in socket connection?

I have a doubt because in database we are connection to one single databae ,so i can reuse already created one.But for doing chat i may have to connect to different IP address and port .

If number of clent increase socket connection also increases i think there will be performance drawback in this application.Can any one of you tell me how to overcome this problem

Giving up is the easiest thing in the world to do..but holding it together when everything seems like falling apart is true strength!!
with regards, Harish.T
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
Depends on your clients. If they don't know anything about sockets, then how could you "connect" to them?

If they are socket-driven, have them connect to a socket server, and include support for multi-casting in your server software.
Harish Tiruvile
Ranch Hand

Joined: Dec 01, 2005
Posts: 99
Hi Hung,

... and include support for multi-casting in your server software.

Can you please elaborate this ...i didn't got what you said
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Have a look at this article on multicasting. Multicasting has its own set of disadvantages, so there are tradeoffs made when using it.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Socket connection performance
It's not a secret anymore!