• 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

Independent Serwer to Client (!) communication

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone knows how the following problem is solved in application like YahooMessneger etc:
When client starts it connects to server via TCPIP and maintains permanent connection to it. THe server starts new thread and this new thread receives incoming messages, process them and sends back result. So far, so simply. But !
How, then, server communicates to client an "independent" event (ie: "User John is now online") THere is no new connection made to client from server. THis is for sure. The message goes via the connection that client initiates. On the server side it is not a problem - server just "push" the message to output stream. But the client expects message only when it has sent previosuly something to server (!) One may add a thread to a client that is only waiting for messages from server, but then how client may tell whether something that is coming from the server is the answer to request or a notification of an independent event?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
I think its all the protocol.
server program may me sending(just eg)
________
CTRL: info like some one loging in etc.(independent event)
USRD user: display information
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think so too, it will be all in the protocol.
My yahoo client will have a list of friends, who it contacts, when I start it up.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I think it is relatively simple. U create a class that sends requests only and a message listener.
message listener is a thread that listens to events from the server.
RequestSender opens connection to the server sends a request and waits for the reply on the same connection.
The problem is, what happens if the server cannot initiate connection to the client due to the FW.
What happened to me is there is a FW between S and C. so only client can initiate the connection and only on the range of ports. So how do i open connection to the server and make the server to switch the connection to a random local port so it is dedicated to the connected client?
Any idea?
this way u have async communication.
reply
    Bookmark Topic Watch Topic
  • New Topic