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

 所属分类:web前端开发

 浏览:79次-  评论: 0次-  更新时间:2023-10-08
描述:更多教程资料进入php教程获得。 To use sockets, consider the WebSocket interface in JavaScript. This interface enabl...
更多教程资料进入php教程获得。

如何在JavaScript/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.

socket . send( data )

以上用于发送数据。

用于关闭套接字连接。

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

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

socket . url
积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!