PHP前端开发

如何在JavaScript/HTML中使用套接字?

百变鹏仔 4周前 (09-21) #HTML
文章标签 如何在

To use sockets, consider the WebSocket interface in JavaScript. This interface enables web applications to maintain bidirectional communications with server-side processes.

为了使Web应用程序能够与服务器端进程保持双向通信,该规范引入了WebSocket接口。

以下是一些解决Web Sockets的方法:

socket = new WebSocket(url [, protocols ] )

Create a new socket using this, wherein parameters URL is a string for the connection and protocols is a string or array of string.

立即学习“Java免费学习笔记(深入)”;

socket . send( data )

以上用于发送数据。

用于关闭套接字连接。

socket . close( [ code ] [, reason ] )

以下返回用于建立连接的URL。

socket . url