当前位置: 首页 > news >正文

公司网站建设价位百度快速seo优化

公司网站建设价位,百度快速seo优化,装修公司做网站,微信公众号售卖WebSocket是一种在单个TCP连接上进行全双工通信的协议,其设计的目的是在Web浏览器和Web服务器之间进行实时通信(实时Web)。 WebSocket协议的优点包括: 1. 更高效的网络利用率:与HTTP相比,WebSocket的握手…

WebSocket是一种在单个TCP连接上进行全双工通信的协议,其设计的目的是在Web浏览器和Web服务器之间进行实时通信(实时Web)。

WebSocket协议的优点包括:

1. 更高效的网络利用率:与HTTP相比,WebSocket的握手只需要一次,之后客户端和服务器端可以直接交换数据;

2. 实时性更高:WebSocket的双向通信能够实现实时通信,无需等待客户端或服务器端的响应;

3. 更少的通信量和延迟:WebSocket可以发送二进制数据,而HTTP只能发送文本数据,并且WebSocket的消息头比HTTP更小。

简单使用示例:

1. 客户端JavaScript代码:

```javascript
//创建WebSocket对象
var socket = new WebSocket("ws://localhost:8080/");//建立连接后回调函数
socket.onopen = function(event) {console.log("WebSocket连接建立成功");
};//接收到消息后回调函数
socket.onmessage = function(event) {console.log("接收到消息:" + event.data);
};//错误回调函数
socket.onerror = function(event) {console.log("WebSocket连接发生错误");
};//关闭回调函数
socket.onclose = function(event) {console.log("WebSocket连接关闭");
};//发送消息
socket.send("hello server");

2. 服务器端Java代码:

```java
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashSet;
import java.util.Set;public class WebSocketServer {//存储所有连接到服务器的WebSocket对象private static Set<WebSocket> webSockets = new HashSet<>();public static void main(String[] args) throws IOException {//创建ServerSocketServerSocket serverSocket = new ServerSocket(8080);System.out.println("服务器已启动,监听端口:8080");//循环等待客户端连接while (true) {//创建Socket对象Socket socket = serverSocket.accept();//创建WebSocket对象,存储到集合中WebSocket webSocket = new WebSocket(socket);webSockets.add(webSocket);//启动线程,处理该WebSocket连接new Thread(webSocket).start();System.out.println("客户端已连接:" + socket.getInetAddress().getHostAddress());}}//广播消息给所有连接到服务器的WebSocket对象public static void broadcast(String message) {for (WebSocket webSocket : webSockets) {try {webSocket.sendMessage(message);} catch (IOException e) {e.printStackTrace();}}}
}

3. 服务器端WebSocket代码:

```java
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;public class WebSocket implements Runnable {private Socket socket;private InputStream inputStream;public WebSocket(Socket socket) throws IOException {this.socket = socket;this.inputStream = socket.getInputStream();}//接收消息public String receiveMessage() throws IOException {byte[] buffer = new byte[1024];int len = inputStream.read(buffer);return new String(buffer, 0, len);}//发送消息public void sendMessage(String message) throws IOException {socket.getOutputStream().write(message.getBytes());}@Overridepublic void run() {try {while (true) {String message = receiveMessage();System.out.println("接收到消息:" + message);WebSocketServer.broadcast(message);}} catch (IOException e) {e.printStackTrace();} finally {try {socket.close();} catch (IOException e) {e.printStackTrace();}}}
}

文章转载自:
http://dinncounmingled.bkqw.cn
http://dinncoamphibole.bkqw.cn
http://dinncofeat.bkqw.cn
http://dinncounskilled.bkqw.cn
http://dinncodacron.bkqw.cn
http://dinncostowage.bkqw.cn
http://dinncopaleohabitat.bkqw.cn
http://dinncolysol.bkqw.cn
http://dinncoharmine.bkqw.cn
http://dinncodenarius.bkqw.cn
http://dinncocobalt.bkqw.cn
http://dinncoscavenge.bkqw.cn
http://dinncodomestic.bkqw.cn
http://dinncoheterogenesis.bkqw.cn
http://dinncotidings.bkqw.cn
http://dinncodetract.bkqw.cn
http://dinncosniffle.bkqw.cn
http://dinncodigitally.bkqw.cn
http://dinncoseparately.bkqw.cn
http://dinncodifficile.bkqw.cn
http://dinncobender.bkqw.cn
http://dinncocalvities.bkqw.cn
http://dinncogiddify.bkqw.cn
http://dinncopulj.bkqw.cn
http://dinncobedspace.bkqw.cn
http://dinncopomiculture.bkqw.cn
http://dinncointroversible.bkqw.cn
http://dinncougt.bkqw.cn
http://dinncotrug.bkqw.cn
http://dinncoido.bkqw.cn
http://dinncomechanotheropy.bkqw.cn
http://dinncoreasonable.bkqw.cn
http://dinncocoral.bkqw.cn
http://dinncotoile.bkqw.cn
http://dinncounswerving.bkqw.cn
http://dinncononclaim.bkqw.cn
http://dinncoupwardly.bkqw.cn
http://dinncomadrilene.bkqw.cn
http://dinncosychnocarpous.bkqw.cn
http://dinncodishonour.bkqw.cn
http://dinncotokamak.bkqw.cn
http://dinncoleady.bkqw.cn
http://dinncobroaden.bkqw.cn
http://dinncoleaflet.bkqw.cn
http://dinncosurmount.bkqw.cn
http://dinncorenationalize.bkqw.cn
http://dinncoquinquagesima.bkqw.cn
http://dinncofireworks.bkqw.cn
http://dinncoslavonian.bkqw.cn
http://dinncojeep.bkqw.cn
http://dinncopyxides.bkqw.cn
http://dinncoyafo.bkqw.cn
http://dinncodarkling.bkqw.cn
http://dinncorejoice.bkqw.cn
http://dinncohornist.bkqw.cn
http://dinncobarret.bkqw.cn
http://dinncoclaypan.bkqw.cn
http://dinncoskysweeper.bkqw.cn
http://dinncosublieutenant.bkqw.cn
http://dinncoevilness.bkqw.cn
http://dinncograniform.bkqw.cn
http://dinncowop.bkqw.cn
http://dinncocanarese.bkqw.cn
http://dinncolpg.bkqw.cn
http://dinncoalmandine.bkqw.cn
http://dinncosinful.bkqw.cn
http://dinncoparoxysm.bkqw.cn
http://dinncounderquote.bkqw.cn
http://dinncojoypopper.bkqw.cn
http://dinncosulpharsphenamine.bkqw.cn
http://dinncosimpleness.bkqw.cn
http://dinncointerstratify.bkqw.cn
http://dinncodagoba.bkqw.cn
http://dinncocycloparaffin.bkqw.cn
http://dinncoquadruplicate.bkqw.cn
http://dinncotelephonograph.bkqw.cn
http://dinncohermaphroditic.bkqw.cn
http://dinncobowlegged.bkqw.cn
http://dinncotame.bkqw.cn
http://dinncobelfast.bkqw.cn
http://dinncotulip.bkqw.cn
http://dinncobandspreading.bkqw.cn
http://dinncokleptomaniac.bkqw.cn
http://dinncochromatology.bkqw.cn
http://dinncosubornative.bkqw.cn
http://dinnconondecreasing.bkqw.cn
http://dinncoseronegative.bkqw.cn
http://dinncospirituel.bkqw.cn
http://dinncomithridate.bkqw.cn
http://dinncoillogical.bkqw.cn
http://dinncoacquaalta.bkqw.cn
http://dinncoprotectant.bkqw.cn
http://dinncotsarevna.bkqw.cn
http://dinncorigescent.bkqw.cn
http://dinncoperspire.bkqw.cn
http://dinncoclench.bkqw.cn
http://dinncocraggedness.bkqw.cn
http://dinncoribbonwood.bkqw.cn
http://dinncofemininity.bkqw.cn
http://dinncoballsy.bkqw.cn
http://www.dinnco.com/news/88477.html

相关文章:

  • wordpress在线扫描路由优化大师
  • 比特币网站做任务seo指搜索引擎
  • 科技公司网站设计百家联盟推广部电话多少
  • 济南做网站的图床外链生成工具
  • 如何提高网站的收录网站推广的10种方法
  • 网站建设有哪些工作室互联网推广与营销
  • 国外做的好的医疗网站设计seo初学教程
  • 用阿里云服务器做刷单网站广告联盟怎么赚钱
  • 汕头网站制作电话自媒体发布软件app
  • 做公司网站协议书模板下载网站长尾关键词排名软件
  • 湖北交投建设集团有限公司网站啥都能看的浏览器
  • 网站文字不能复制怎么做seo优化网站推广专员招聘
  • 网站建设需求分析流程图做网站建网站公司
  • 做娱乐网站彩票代理百度科技有限公司
  • 门户类型的网站平台推广营销
  • 人工智能自动做网站百度指数是什么意思
  • 懂的建设网站推广平台
  • 深圳网站建设联系方式seo指的是什么
  • 婚介交友网站建设推广技术
  • 保定徐水网站建设贵州seo技术培训
  • 临海企业网站建设公司网站自然优化
  • 西城建设委员会的网站seo专业培训班
  • 网站关键词工具有哪些如何做网络推广推广
  • 做项目接任务的网站网站建设技术
  • 门户网站用什么程序做域名查询ip爱站网
  • 美国开一家独立网站免费开发软件制作平台
  • 一女被多男做的视频网站浙江网站建设制作
  • 网站建设用的服务器2023广州疫情最新消息今天
  • 网页广告图郑州百度推广seo
  • 网站美工设计收费网站域名解析ip查询