如何实现从servlet到服务器到客户端的中断驱动通信? [英] How to achieve interrupt-driven communication from server to client with servlets?

查看:116
本文介绍了如何实现从servlet到服务器到客户端的中断驱动通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用C ++写的基于发送屏幕截图的屏幕共享应用

we wrote in C++ a screen sharing application based on sending screenshots.

它通过在服务器和客户端建立TCP连接来工作,其中服务器通过连接转发为用户接收的每个新的屏幕截图,并由客户端弹出。

It works by establishing a TCP connection btw the server and client, where the server forwards every new screenshot received for a user through the connection, and this is popped-up by the client.

现在,我们试图在google app引擎上托管这个服务器,因此需要'servlet'-ize和'sandbox'服务器代码, HTTP请求。

Now, we are trying to host this on google app engine, and therefore need 'servlet'-ize and 'sandbox' the server code, so to implement this forwarding through HTTP requests.

我的意思如下:
1.将截图作为多数据形式发送请求(apache上传..)。
但现在服务器需要联系指定的客户端(谁登录)发送/转发屏幕截图。
我不知道如何启动从servlet到客户端的连接。客户端不运行任何servlet环境(当然)。
我知道HTTP 1.1连接一个TCP连接,但似乎gapps不会让我使用它。

I immagine the following: 1. Post request with the screenshot as multiple-data form (apache uploads ..). But now the server needs to contact the specified client (who is logged in) to send it/forward the screenshot. I'm not sure how to 'initiate' such connection from the servlet to the client. The client doesn't run any servlet environment (of course). I know HTTP 1.1 mantains a TCP connection, but it seems gapps won't let me use it.

想到的1种方法是发送在登录时继续每个登录用户100,并在屏幕截图到达后回复。在接收到客户端提出另一个请求,等等。
一个替代方法(设置浏览器的刷新标头)将定期有应用程序池(每5秒)。

1 approaches that comes to mind is to send a CONTINUE 100 to every logged in user at login, and respond with the screenshot once it arrives. Upon receival the client makes another request, and so on. an alternative (insipired from setting the refresh header for a browser) would be to have the app pool on a regular basis (every 5 secs).

推荐答案

您无法在GAE上有效地完成这项工作。

You're not going to be able to do this effectively on GAE.

问题1:所有输出都被缓冲,直到您的处理程序返回

问题2:配额&限制:


一些功能强制限制无关
到配额以保护
的稳定性系统。例如,当调用
应用程序来服务web
请求时,它必须在30秒内发出响应
。如果应用程序
花费的时间过长,则过程是
终止,服务器向用户返回
错误代码。请求
超时是动态的,并且如果请求处理程序经常达到
其超时以便节省
资源,则可以
缩短。

Some features impose limits unrelated to quotas to protect the stability of the system. For example, when an application is called to serve a web request, it must issue a response within 30 seconds. If the application takes too long, the process is terminated and the server returns an error code to the user. The request timeout is dynamic, and may be shortened if a request handler reaches its timeout frequently to conserve resources.

彗星支持在产品路线图< a>,但对我来说,您的应用程序仍然似乎不适合GAE应用程序。

Comet support is on the product roadmap, but to me your app still seems like a poor fit for a GAE application.

这篇关于如何实现从servlet到服务器到客户端的中断驱动通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆