使用WebSockets进行跨平台通信 [英] Using WebSockets for cross-platform communication

查看:78
本文介绍了使用WebSockets进行跨平台通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我正在尝试在Windows PC上找到Web应用程序和桌面应用程序之间的通信方法。目前我有一组用C ++(MFC)编写的用于Windows桌面环境的应用程序。他们可以使用TCP套接字在本地或通过LAN进行相互通信。



我正在考虑创建简单的Web应用程序(我想让它在智能手机上运行) ,它将能够通过互联网连接到PC并与之交换信息。



我目前没有网络技术方面的经验,所以可能我完全看错了方向,但这是我的想法:



1.我需要编写将运行的Web应用程序(HTML / Java)在任何有互联网连接的智能手机的浏览器(比如保存在本地磁盘上的网页)



2.我需要为Windows写一个服务器应用程序,它将把所需数据传递给网络应用程序



3.我需要找到一种在2之间进行持续沟通的方式。



做了一些研究之后我认为WebSockets是很好的解决方案。我找到了很少的演示项目,我和它们一起玩,但每次都有同样的问题:我可以在本地或局域网中从浏览器连接到服务器,但是当我尝试使用外部IP地址时它没有连接。那么我读到路由器(或ISP)阻止大多数端口,这可能是问题的原因。然而,转发端口和配置路由器对我的解决方案来说并不实用 - 我必须为每个客户端执行此操作。

然后我发现使用Secure Websocket(wss)应该有助于处理路由器等等上。我试过了,但仍然没有快乐。



所以我的问题是:在这种情况下,websocket是正确的沟通方式还是我应该在其他地方看看?


提前谢谢

Hi
I''m trying to find a communication method between web application and desktop application on Windows PC. At the moment I have a group of applications written in C++ (MFC) for Windows desktop environment. They can communicate between each other using TCP sockets - locally or over LAN.

I''m thinking about creating simple web application (I want it to run on smartphones), which will be able to connect to the PC via internet and exchange information with it.

I don''t have experience in web technologies at the moment, so possibly I''m looking in wrong direction completely, but here is my idea of it:

1. I need to write web application (HTML / Java) which will run in browser on any smartphone with internet connection. (like web page saved on local disk)

2. I need to write a ''server'' application for Windows which will pass required data to the web app

3. I need to find a way of continuous communication between the 2.

After doing some research I think WebSockets are good solutions for it. I found few demo projects, and I played with them, but every time, I have the same problem: I can connect from browser to server locally or in LAN, but it doesn''t connect when I try to use my external IP address. So then I read that routers (or ISPs) are blocking most ports, which probably is a reason of the problem. However forwarding ports and configuring routers is not practical for my solution - I would have to do it for every client.
So then I found that using Secure Websocket (wss) should help with dealing with routers and so on. I tried that, but still no joy.

So my question is: is the websocket right way of communication in this situation or should I look somewhere else?

Thanks in advance

推荐答案

这关键取决于您可以使用哪种服务器端技术。在许多情况下,它仍然可以是TCP,但防火墙问题。例如,使用ASP.NET,您可以使用WCF的强大功能。根据您对情况的了解,做出决定性建议是不可能的。



-SA
It really depends critically on what server-side technology you can use. In many cases, it still can be TCP, but firewalls the problem. For example, with ASP.NET you can use the power of WCF. It''s just impossible to make a decisive recommendation based on limiting knowledge of your situation.

—SA


这篇关于使用WebSockets进行跨平台通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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