How can a server communiate with two clients at once (JavaScript, HTML, PHP)? -


i got assignment , use www technology html, javascript, php etc. i'm sorry haven't studied of these technologies. therefore took few tutorials , skimmed through them searching answers.

i found solutions many problems 1 problem yet unsolved. this:

i want 2 clients communicate through server assignment. 1 send message, server processes , forwards next.

none of php tutorials showed me anyway of doing this. of them talked of communication between 1 client server.

please help. show me way this. thanks.

currently, without reverting cutting-edge (and possibly hacky/unreliable) techniques, php server cannot initiate communications page you've loaded web browser. result of way http protocol works.

one way solve polling on "receiving" end data. publish-subscribe pattern.

one way be:

  1. one client sends data server using http request (xhr aka ajax) specifying target data (the other client).
  2. the server stores data in persistent storage (local file, database, etc).
  3. the second client periodically sends request server asking if there's new data consume. can done using setinterval , xhr in javascript.

i suggest take at:

http://en.wikipedia.org/wiki/publish/subscribe

and also, cutting edge way this, check out socket.io:

http://socket.io


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -