2.2. Polling Method
In general, HTTP is a method in which the client sends a request to the server, and
subsequently the server responds. Unlike socket programming, HTTP is closer to one-way
rather than two-way communication; it was not designed to enable servers to push messages
to clients. However, as web communications have gradually become more complex, various
technologies to push data from the server to the client have been designed [12]. This led to
the invention of Ajax, a periodic polling method. However, Ajax’s polling method is very
inefficient, and is lacking in capability to transfer data in real time. Therefore, several other
methods began to appear, although none of them really integrated seamlessly with HTTP.
One resulting method is Comet, also known as Reverse Ajax. Comet employs a long polling
method, using a script tag and XHR streaming system utilizing hidden HTML IFrames.
Streaming is a method in which the client and server maintain a connection. Each event
represents the transmission of data to the client. When data is requested by the client, the
server side remains connected and sends messages in succession without requiring a response.
This method does not require client requests to continue, but requires simultaneous
connections, and can be adversely affected by the number of connections.
In the long polling method, an HTTP request is sent and a response received, similar to the
streaming method. However, after loading the page, it sends the request using a separate
XMLHttpRequest (XHR) script; if the server does not immediately send a response to it, an
event is generated on the server side [13]. A response is then transmitted to the client. By
using this method, when an event occurs in the server, it is possible to transmit the data to the
client in real time. However, after sending a response, the connection between the client and
the server is disconnected. Fig 3 displays a comparison of Ajax, long polling, and streaming
methods.