![](https://img-blog.csdnimg.cn/20190927151053287.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
TCP/UDP
TCP/UDP
热爱技术的小陈
于上市互联网企业工作十来年,从程序员到技术总监,从.net到php到java再到大数据,喜欢研究新技术
展开
-
linux服务器TCP相关设置
linux服务器TCP相关设置原创 2023-04-20 09:00:20 · 789 阅读 · 1 评论 -
手写DubboRPC
手写DubboRPC原创 2022-01-21 20:00:25 · 280 阅读 · 0 评论 -
RPC基本介绍
RPC基本介绍原创 2022-01-21 10:46:12 · 3263 阅读 · 0 评论 -
Netty 异步线程池Context方式
EchoClient/* * Copyright 2012 The Netty Project * * The Netty Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the L原创 2022-01-21 10:37:00 · 2426 阅读 · 0 评论 -
Netty 异步线程池handler方式
EchoClient/* * Copyright 2012 The Netty Project * * The Netty Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the L原创 2022-01-21 10:35:19 · 296 阅读 · 0 评论 -
Netty 异步线程池 handler与context方式对比
handler与context方式对比原创 2022-01-20 15:19:55 · 324 阅读 · 0 评论 -
Netty 阻塞线程池案例
案例结果,都是添加到同个线程EchoServerpublic final class EchoServer { static final boolean SSL = System.getProperty("ssl") != null; static final int PORT = Integer.parseInt(System.getProperty("port", "8007")); public static void main(String[] args) thro原创 2022-01-20 13:15:55 · 600 阅读 · 0 评论 -
Netty 开发文档
Netty 开发文档 https://netty.io/4.1/api/index.html原创 2022-01-14 20:07:55 · 1524 阅读 · 0 评论 -
Netty源码解读
Netty源码解读原创 2022-01-14 19:55:20 · 401 阅读 · 0 评论 -
如何解决TCP粘包与拆包
TCP粘包与拆包解决方案原创 2022-01-14 19:45:00 · 452 阅读 · 0 评论 -
模拟TCP粘包拆包问题
官网下载https://netty.io/下载完后解压,用IDEA打开,example中都是案例echo为最常规“客户端-服务端”案例原创 2022-01-14 14:59:12 · 268 阅读 · 0 评论 -
什么是TCP粘包与拆包
TCP粘包与拆包基本介绍原创 2022-01-14 13:04:35 · 1138 阅读 · 0 评论 -
Java Protobuf 多类型实例
maven 中心找到protobuf坐标 https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> &原创 2022-01-13 22:00:28 · 333 阅读 · 0 评论 -
Java Protobuf 单类型实例
maven 中心找到protobuf坐标 https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> &原创 2022-01-13 17:49:16 · 164 阅读 · 0 评论 -
Protobuf怎么使用
下载解压官网 https://github.com/protocolbuffers/protobuf/releases 找到java版本(找到自己需要的语言)把要编译的文件拷入bin目录中Student.protosyntax = "proto3";//版本option java_outer_classname = "StudentPOJO";//生成的外部类名,同时也是文件名//protobuf 使用message 管理数据message Student{//会在Student外部类生成一原创 2022-01-13 17:39:17 · 759 阅读 · 0 评论 -
websocket socket xmpp区别
socket是套接字,在你的语境下,多指传输层网络接口。webSocket,是一个应用层协议,说的是,目前浏览器实现的一套通信协议,用来解决之前HTTP,请求响应模型不合适的场合。XMPP,是一个应用层协议,协议基于XML结构设计...原创 2022-01-13 16:37:23 · 994 阅读 · 0 评论 -
OSI七层网络模型
原创 2022-01-13 16:23:36 · 604 阅读 · 0 评论 -
HTTP、websocket、XMPP、COAP、MQTT和DDS协议对比
对于物联网,最重要的是在互联网中设备与设备的通讯,现在物联网在internet通信中比较常见的通讯协议包括:HTTP、websocket、XMPP、COAP、MQTT1、HTTP和websocket在互联网时代,TCP/IP协议已经一统江湖,现在的物联网的通信架构也是构建在传统互联网基础架构之上。在当前的互联网通信协议中,HTTP协议由于开发成本低,开放程度高,几乎占据大半江山,所以很多厂商在构建物联网系统时也基于http协议进行开发。包括google主导的physic web项目,都是期望在传统web原创 2022-01-13 16:07:42 · 507 阅读 · 0 评论 -
长轮询与长连接
长轮询客户端向服务器发送Ajax请求,服务器接到请求后hold住连接,直到有新消息才返回响应信息并关闭连接,客户端处理完响应信息后再向服务器发送新的请求。优点:在无消息的情况下不会频繁的请求,耗费资源小。缺点:服务器hold连接会消耗资源,返回数据顺序无保证,难于管理维护。实例:WebQQ、Hi网页版、Facebook IM。长连接在页面里嵌入一个隐蔵iframe,将这个隐蔵iframe的src属性设为对一个长连接的请求或是采用xhr请求,服务器端就能源源不断地往客户端输入数据。优点:消息即时原创 2022-01-13 15:43:53 · 1895 阅读 · 0 评论 -
IM 协议 IMPP、PRIM、SIMPLE、XMPP
MQTT基于xmpp协议 Openfire、Tigase、Prosody、Mosquitto、ejabberd原创 2022-01-08 18:47:12 · 1510 阅读 · 0 评论 -
Java NIO聊天室代码
服务端public class Server { //backlog为accept队列大小,默认值为50 private static final int BACKLOG = 1024; private static final String IP = "127.0.0.1"; private static final int PORT = 8888; private ServerSocketChannel serverChannel; private Se原创 2022-01-06 15:54:08 · 154 阅读 · 0 评论 -
Java BIO手写简易版tomcat
public class tomcat { public static final String SEPARATOR = "\r\n"; public static final int BACK_LOG = 1024; public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; Socket socket = null;原创 2022-01-02 21:53:37 · 233 阅读 · 0 评论 -
Java 网络资源下载代码
public class download { public static void main(String[] args) { FileOutputStream fos = null; InputStream inputStream = null; HttpURLConnection urlConnection =null; try { URL url = new URL("https://t7.baidu.原创 2022-01-02 17:31:29 · 160 阅读 · 0 评论 -
Java UDP多线程在线聊天
发送类//udp不需要连接服务器public class send implements Runnable { //建立一个socket DatagramSocket socket = null; BufferedReader reader = null; private String toIP; private int toPort; public send(String toIP, int toPort) { this.toIP =原创 2022-01-02 17:04:41 · 911 阅读 · 0 评论 -
TCP三次握手四次挥手
TCP三次握手四次挥手原创 2022-01-01 12:43:28 · 326 阅读 · 0 评论 -
Java 传统BIO聊天代码
客户端1,连接服务器socket2,发送消息public class tcpClient { public static void main(String[] args) { Socket socket = null; OutputStream outputStream = null; try { InetAddress inetAddress = InetAddress.getByName("127.0.0.1");原创 2022-01-01 17:55:46 · 149 阅读 · 0 评论 -
Java 传统BIO文件传输上传拷贝
客户端 public static void main(String[] args) { Socket socket = null; OutputStream outputStream = null; FileInputStream fileInputStream = null; InputStream inputStream = null; ByteArrayOutputStream byteArrayOutputSt原创 2022-01-02 11:48:45 · 279 阅读 · 0 评论 -
Java UDP聊天室-消息发送接收
发送端 public static void main(String[] args) { //建立一个socket DatagramSocket socket = null; try { socket = new DatagramSocket(); //建立包 String msg="我是一个udp包"; //发送 DatagramP原创 2022-01-02 12:21:53 · 352 阅读 · 0 评论