File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Using sockets to store how many users connected. 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 "Using sockets to store how many users connected." Watch "Using sockets to store how many users connected." New topic
Author

Using sockets to store how many users connected.

Gustavo Siqueira
Ranch Hand

Joined: Jun 15, 2011
Posts: 97

In order to learn better regards between protocols TCP/IP and Socket, I solved make a simple web chat (desktop). I need to knows how many users are connected to socket, so I thought in store objects sockets in a ArrayList<Socket> in then return object socket for RMI. That's the better idea to that ? Other issue: How do I send the message to particular socket connected ?
Can someone me give advice ? Thank you!
Sachin H. Gupta
Greenhorn

Joined: Oct 10, 2012
Posts: 16
I need to knows how many users are connected to socket


Does that mean "How many users are online ?". Since you have maintained list of connected sockets in Arraylist<Socket> you can easily determine that.

How do I send the message to particular socket connected ?


You need to get an OutputStream on that Socket and send your messages using that.
 
 
subject: Using sockets to store how many users connected.
 
Similar Threads
Socket
Sockets, threads and JDBC - design question
Using sessions in a web / non-web environment
query ip
Multichat Application