开发者

Implement a Web based Client that interacts with a TCP Server

EDIT:Question Updated. Thanks Slott.

I have a TCP Server in Python.

It is a server with asynchronous behaviour. .

The message format is Binary Data.

Currently I have a python client that interacts with the code.

What I want to be able to do eventually implement a Web bas开发者_如何学运维ed Front End to this client.

I just wanted to know , what should be correct design for such an application.


Start with any WSGI-based web server. werkzeug is a choice.

The Asynchronous TCP/IP is a seriously complicated problem. HTTP is synchronous. So using the synchronous web server presenting some asynchronous data is always a problem. Always.

The best you can do is to buffer things and have two processes in your web application.

  1. TCP/IP process that collects data from the remove server and buffers it in a file (or files) somewhere.

  2. WSGI web process which handles GET/POST processing.

    • GET requests will fetch some or all of the buffer and display it.

    • POST requests will send a message to the TCP/IP server.


For Web-based, talk HTTP. Use JSON or XML as data formats.

Be standards-compliant and make use of the vast number of libraries out there. Don't reinvent the wheel. This way you have less headaches in the long run.


if you need to maintain a connection to a backend server across multiple HTTP requests, Twisted's HTTP server is an ideal choice, since it's built to manage multiple connections easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜