Qix*_*Qix 11 javascript html5 header http websocket
好吧,我刚刚在HTML 5中尝试了新的WebSocket类,并且非常兴奋它们存在; 不过,我看不出他们是如何比AJAX更有价值看到,他们怎么还发起HTTP调用,并且不喜欢传统的插座.这就是我在这里问的原因.
有没有办法使用HTML 5的WebSocket类连接到侦听套接字而不发送HTTP数据?目前使用TCP/IP构建器,它显示了我不想要的所有这些标题垃圾(因为我想连接到没有Flash桥或Comet之类的东西的POP3/IMAP服务器).
可能?
连接输出:
Listening for connections...Connected
GET / HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: localhost:666
Origin: null
Sec-WebSocket-Key1: 2 987_390VNw60yi9
Sec-WebSocket-Key2: ~196 Y p 5 P67 428 ?
Run Code Online (Sandbox Code Playgroud)
No. Once the connection is established you have a true socket. But you're right that it requires special server support. So it won't let you connect to an unmodified POP or IMAP server.
They chose that design (the Upgrade mechanism) so you could easily have a server that listened for WebSocket connections as well as true HTTP requests.
There is still a big distinction from AJAX and COMET. You can use WebSockets to have true full-duplex communication between server and client. Previous browser APIs haven't provided that, forcing people to use various work-arounds (such as repeated AJAX requests, COMET's forever frame, and others).
| 归档时间: |
|
| 查看次数: |
10651 次 |
| 最近记录: |