如何建立从Web浏览器(客户端)TCP套接字连接? [英] How to establish a TCP Socket connection from a web browser (client side)?

查看:426
本文介绍了如何建立从Web浏览器(客户端)TCP套接字连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过关于的WebSockets ,但他们似乎并没有被纯粹的插座,因为在他们的应用层协议。 的 WS:

有没有办法做从Web浏览器纯套接字连接,搞活网页?

下面是我随意刺在黑暗中

  • 在小程序在Java提供的插座(需要安装Java)
  • 在闪存由Flash提供的插座(需要安装Flash)

不过,关于HTML5,为什么他们叫的WebSockets,如果他们不接?

时的WebSocket协议那么简单实现,这是几乎-sockets?

解决方案
  

我读过有关的WebSockets,但他们似乎并没有被纯粹的插座,因为在他们的应用层协议。

     

[表示] WebSocket协议那么简单实现的[是]差不多-sockets?

直接从浏览器允许普通插座的连接永远不会发生,因为它开辟了一个巨大的风险。的WebSockets是最接近从浏览器原始套接字,你会得到。初始的WebSockets握手类似于一个HTTP握手(允许Web服务器向代理/缩小的话),并增加了CORS类型的安全性。此外,的WebSockets是一个基于消息的传输(而不是流为原料TCP),这是使用两个字节的头在每个消息帧进行。

即使闪光灯无法挺过这一关原始TCP连接。闪存插槽还可以添加CORS的安全性,但不是带内握手,闪套接字连接使目标服务器请求一个安全策略文件到端口843的连接。

  

有没有办法做从Web浏览器纯套接字连接,搞活网页?

是的,你可以用我的 websockify 桥/代理,它允许的WebSockets通过websockify功能的浏览器,直接连接到TCP套接字

  

不过,关于HTML5,为什么他们叫的WebSockets,如果他们不接?

的WebSockets是建立在TCP套接字传输。握手之后有很小的开销(通常只是一个两字节的头)。

I've read about WebSockets but they don't seem to be pure "sockets", because there is an application layer protocol over them. "ws:"

Is there any way of doing a pure socket connection from a web browser, to enliven webpages?

Here are my random stabs in the dark

  • Applets sockets provided by Java (need java installed)
  • Flash sockets provided by Flash (need flash installed)

But about HTML5, Why are they called WebSockets if they aren't Sockets?

Is the websocket protocol so simple to implement that it is "almost"-sockets?

解决方案

I've read about WebSockets but they don't seem to be pure "sockets", because there is an application layer protocol over them.

[Is the] websocket protocol so simple to implement that [it is] "almost"-sockets?

Allowing regular socket connections directly from the browser is never going to happen because it opens up a huge risk. WebSockets is about as close to raw sockets from the browser as you are going to get. The initial WebSockets handshake is similar to an HTTP handshake (allowing web servers to proxy/bridge it) and adds CORS type security. In addition, WebSockets is a message based transport (rather than streaming as raw TCP) and this is done using a two byte header on each message frame.

Even flash is not able to quite make raw TCP connections. Flash sockets also add CORS security, but instead of an in-band handshake, flash socket connections make a connection to port 843 on the target server to request a security policy file.

Is there any way of doing a pure socket connection from a web browser, to enliven webpages?

Yes, you can use my websockify bridge/proxy which allows a WebSockets enabled browser to connect directly to a TCP socket via websockify.

But about HTML5, Why are they called WebSockets if they aren't Sockets?

WebSockets are a transport built on TCP sockets. After the handshake there is very minimal overhead (typically just a two byte header).

这篇关于如何建立从Web浏览器(客户端)TCP套接字连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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