Can the server initiate a request to the user? Those. If a user has a page open, can the server see this and send something to him?

... the question arose a long time ago, in those times when I still couldn’t really program, and I was given the task to write a chat. Immediately I thought not about the client sending requests and receiving new messages at a specified interval, but about the server sending it to all connected users with a new message.

  • And if to implement through ajax? - atnartur
  • In principle, it is possible, but this is no longer HTTP - alexlz

2 answers 2

Look here: COMET . Described many options with which you can properly carry out your task.

    If you need support for older browsers, then look towards SOMET or Flash p2p. But with the advent of HTML5, the WebSocket protocol appeared, designed to exchange messages between the browser and the web server in real time.