• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

serverSocket

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic