可以Web服务器发送数据,而无需从客户端的请求?客户端、服务器、数据、Web

由网友(唇齿间的故事)分享简介:我有一个工具,它需要的任何时间,从一分钟到几个小时。我想编写一个Web应用程序,使用户能够运行来自网页的工具。由于每个工具的运行需要较长的时间,我想从网页发送工具运行请求,那么我想更新状态信息的页面。用于更新状态信息时,客户端必须轮询服务器。有没有什么办法由哪个服务器可以发送状态信息给客户端,而不要求I have a...

我有一个工具,它需要的任何时间,从一分钟到几个小时。我想编写一个Web应用程序,使用户能够运行来自网页的工具。由于每个工具的运行需要较长的时间,我想从网页发送工具运行请求,那么我想更新状态信息的页面。用于更新状态信息时,客户端必须轮询服务器。有没有什么办法由哪个服务器可以发送状态信息给客户端,而不要求

I have a tool which takes any time from a minute to couple of hours. I want to write a web application to enable users to run the tool from webpage. Since each tool run takes longer time, i want to send the tool run request from the webpage, then i want to update the page with status information. For updating the status information, the client has to poll the server. Is there any way by which server can send the status message to the client without a request

推荐答案

您可以使用网络套接字这是客户端和服务器之间的双向沟通​​是保持开放,并允许发送服务器而无需客户端的请求。然而网络插座新的浏览器支持仅适用于最新的浏览器。

You can use web-sockets which are two way communication between client and server that remain open and allow the server to send without request from the client. However web-sockets are new and browser support is only for the most current browsers.

socket.io 是为网络插座有落差背对着AJAX和一个伟大的图书馆,如果不支持他们闪烁。

socket.io is a great library for web sockets with fall backs to AJAX and flash if they are not supported.

除此之外的唯一的其他方式为服务器将数据发送到客户端是后客户已经发送一个请求。有使用AJAX轮询从客户端的方法来检查来自服务器的更新。

Other than that the only other way for the server to send data to the clients is after the client has sent a request. There is methods using AJAX polling from the client to check for updates from the server.

阅读全文

相关推荐

最新文章