npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lvgithub/stick

v3.1.11

Published

The solution of sticky package problem of TCP for Node.Js !

Downloads

41

Readme

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