如何通过 Web 客户端访问 TCP Socket [英] How to access TCP Socket via web client

查看:92
本文介绍了如何通过 Web 客户端访问 TCP Socket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在嵌入式设备中有一个程序,可以将 xml 字符串输出到套接字.嵌入式设备有 lighthttpd 有一个 web 服务器.我想使用基于 Web 的客户端(无 flash/silverlight)连接到套接字并每秒提取 xml 数据.

I have a program in an embedded device that outputs an xml string to a socket. The embedded device has lighthttpd has a web server. I want to use a web based client (no flash/silverlight) to connect to the socket and pull the xml data every second.

我查看了 Node.js 和 Socket.io 以获得我想要做的事情,但我不清楚如何继续.搜索 Node.js 和 Socket.io 文档和示例,我看到了标准的客户端-服务器行为,与我想要做的事情无关.

I looked at Node.js with Socket.io to get what I want to do, but I am not clear about how to proceed. Searching through the Node.js and Socket.io documentation and examples I see standard client-server behavior, nothing regarding what I am trying to do.

基本上,Web 服务器只是在那里接受来自嵌入式应用程序正在向其输出数据的套接字上的客户端的连接.基本上,Web 服务器的目的是让客户端从嵌入式应用程序正在写入的原始 tcp 套接字中检索数据.请指教.

Basically, the web server is just there to accept a connection from a client on the socket that the embedded application is outputting data to. Basically the web server's purpose is to just let the client retrieve data from the raw tcp socket that the embedded application is writing to. Please advice.

推荐答案

我使用 Websockify 解决了这个问题,它充当 TCP 套接字和浏览器之间的桥梁.

I solved the problem using Websockify, which acts as bridge between a TCP Socket and a browser.

html 客户端会连接到一个 websocket,Websockify 会监听 websocket 端口并在 websocket 和 tcp socket 之间传输数据.

The html client will connect to a websocket, and Websockify will listen on the websocket port and transmit data between the websocket and the tcp socket.

这篇关于如何通过 Web 客户端访问 TCP Socket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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