• Post Reply Bookmark Topic Watch Topic
  • New Topic

serverSocket

 
jambeard lewistrix
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a server socket send messages like a normal Socket?

At the moment I have a client (of type Socket) which can send / receive messages by writing to / reading from a stream.

I have a server which, when a client connects, starts a new thread which then deals with communication to / from that client.

I want the server to be able to send urgent messages to ALL clients that are currently logged on but have no idea how to do this! Any suggestions?

J
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is to reverse roles so the clients become servers and the server becomes a client. Each client starts up a server socket and "registers" with the server at logon by sending the address. When the server wants to blast a message it iterates through the registered clients, does connect, send, disconnect. This is not instantaneous. If you have lots of clients it may take a while, especially if some of them time out or fail in unclean ways.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!