Git Product home page Git Product logo

Comments (11)

xuuhaoo avatar xuuhaoo commented on May 17, 2024

这个是防止内存溢出的错误,说明你服务器返回的数据格式不对(包头中的包体长度不正确)

from oksocket.

xuuhaoo avatar xuuhaoo commented on May 17, 2024

image
你的Socket服务器应该返回数据格式按照 [包头][包体]的格式,包头中默认的Header处理是直接解析包头数据为后面的包体长度,你可以重写包头解析方法,来适应你的服务器返回,从中返回正确的包体长度,如上图这个方法,是设置自定义包头解析类的

from oksocket.

xuuhaoo avatar xuuhaoo commented on May 17, 2024

我已经更新了文档,你可以看下

from oksocket.

BadDeveloper2022 avatar BadDeveloper2022 commented on May 17, 2024

每一个包是 \n 来分包的,这个怎么解析?

from oksocket.

BadDeveloper2022 avatar BadDeveloper2022 commented on May 17, 2024

还有一个问题:我重写了那个接口,但是不知道当前的接受的数据,怎么知道一个包Body长度呢?

from oksocket.

BadDeveloper2022 avatar BadDeveloper2022 commented on May 17, 2024

有时间帮我解决一下,谢谢:QQ 253933559

from oksocket.

 avatar commented on May 17, 2024

我也是遇到这个问题, 怎么自定义包头和包体 ?

from oksocket.

BadDeveloper2022 avatar BadDeveloper2022 commented on May 17, 2024

目前为止好像不支持自定义分包

from oksocket.

 avatar commented on May 17, 2024

QQ 58461882 , 求大佬支援

from oksocket.

 avatar commented on May 17, 2024

或者说这个 服务器 发送的 格式是什么

from oksocket.

xuuhaoo avatar xuuhaoo commented on May 17, 2024

例如服务端要给你发送一个英文字母 a
那么服务端应该这样发送 byte 数组
00 00 00 01 61

解释如下:
a 的 Ascll 码对应的是97 97的16进制是0x61
a 的数据长度是1
所以包头要标识后面的包体长度是1
所以包头就是1
因为包头是 int 型,一个 int 型战4个字节
所以,就是00 00 00 01
要发送的数据长度 + 发送的数据
所以就是 00 00 00 01 61

from oksocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.