处理系统命令和http请求的套接字服务器
几周来我一直在寻找并尝试找到一个我可以理解并轻松实施的解决方案来解决我的问题,但我并没有感到高兴。因此,如果有人能让我摆脱痛苦,我将非常感激。
我正在构建一个 iPhone 应用程序,其功能类似于“Air Video”和“Air Playit”等应用程序。该应用程序应与远程主机上运行的服务器进行通信。该服务器应该能够执行 iPhone 发送的命令,对视频进行编码并通过 http 进行流式传输。
就我而言,我的 iPhone 应用程序发送要在远程主机上执行的命令。远程主机正在运行一个 python 套接字服务器,例如在端口 3333 上进行侦听。 在iPhone上,我只是使用
“CFStreamCreatePairWithSocketToHost”、“CFWriteStreamOpen”和 “CFReadStreamOpen”
用于连接、写入和读取数据。
我的远程主机成功拦截命令并开始编码。 为了提供内容,我必须运行一个单独的 http 服务器(我正在使用 Python simpleHTTPServer),它正在侦听另一个端口。
我想做的是对系统命令和 http 请求使用相同的端口。 我上面提到的应用程序似乎就是这样做的,我注意到它们有自己的内置网络服务器。
我确信我错过了一些东西,但请耐心等待,这是我第一次尝试构建应用程序。
i've been searching and trying for weeks now to find a solution to my issue that I can understand and easily implement but I had no joy. So i would be very grateful if someone could put me out of my misery.
I'm building an iphone app similar in functionality to apps like "Air Video" and "Air Playit". The app should communicate with a server running on a remote host. This server should be able to execute a command sent by the iphone to encode a video and stream it over http.
In my case, my iphone app sends commands to be executed on a remote host. the remote host is running a python socket server listening for example on port 3333.
On the iphone, i'm simply using
"CFStreamCreatePairWithSocketToHost", "CFWriteStreamOpen" and
"CFReadStreamOpen"
to connect, write and read data.
My remote host, successfully intercepts the commands and starts the encoding.
To serve the contents, I'm having to run a separate http server (i'm using Python simpleHTTPServer) which is listening on another port.
What I would like to do is use the same port for both system commands and http requests.
The apps I've mentioned above seem to do it that way and I've noticed they have their own build-in web server.
I'm sure I'm missing something but please bear with me this is my first attempt at building an app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将系统命令编码为特殊的 HTTP 请求。根据 HTTP 请求而不是传入端口决定要执行哪些操作(执行命令或提供内容)。如果您需要使用单独的 http 服务器(就像您所说的那样),请考虑使用一个层来接收来自设备的所有内容并根据请求分派到其他服务器(或端口)。
Encode your system commands into special HTTP requests. Decide which thing to do (execute command or serve the contents) based on HTTP request, not on the incoming port. If you need to use separate http servers (like you told), consider having a layer that receives everything from the devices and dispatches to other servers (or ports) based on the request.