GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lvgithub/stick: solution of "sticking packets" for TCP network transmission

BranchesTags
Open more actions menu

Latest commit

 

History

163 Commits
163 Commits

Folders and files

NameName
Last commit message
Last commit date
assets/README
assets/README
 
 
docs
docs
 
 
examples
examples
 
 
lib
lib
 
 
test
test
 
 
typings
typings
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
README_EN.md
README_EN.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
publish.sh
publish.sh
 
 

Repository files navigation

issues forks stars linces npm david downloads

🌈 Introduction

我们使用 TCP 通信的时候,由于TCP是面向流的,因此需要对流进行解析。也就是所谓的拆包,把流解析为一段段我们所需要的数据。本方案为 Node.Js 实现的一个处理方案。

对要发送的数据按协议编码,把数据 data 分为 header +body 两部分,header 默认固定长度(2 byte),header描述的是 body 数据的长度。由于header定长,因此可以通过header,解析出 body 的内容。

默认 header 我们使用 2 Byte 的存储空间,即Int16最大表示的 body 长度为 32767,也就是16M。

Schematic

如上图,我们看先取出数据流的前两位,读取到内容 0x00, 0x02转化为整数的长度是 2,再读取出body第3、4位 0x61, 0x62。

Links

🌈 Install

👀 Getting Started

😊 API Reference

😸 Examples

🌍 Solve the problem of "sticking packets" for TCP network transmission (Classic)

Other Language

现实场景中客户端是其他语言编写的比如C语言运行在单片机上,这时候大家可以基原理图自行打包,规则所示:

data = header(body.length) + body

License

MIT

About

solution of "sticking packets" for TCP network transmission

Topics

bytesnetnodenodejspackagesocketsticktcp

Resources

Readme
MIT license
Activity

Stars

293 stars

Watchers

27 watching

Forks

52 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.