Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using sockets to store how many users connected.

 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic