Skip to content

net.createServer 分片问题 #23

Description

@nxycdl

你好。我看了你的写的文档,写的非常详细,想咨询一个问题。我按照文档弄了一个socket程序, 发现client 发过来的一条消息,内容比较小的时候没有问题,内容大的时候被服务器进行分片接收了,如下代码的YYYY被打印了多次,将这些接收到的数据要合并在一起就是client的原始消息, 想咨询下你又没有什么办法能把分片的socket请求合并在一起,然后执行dosomething() 方法。

const server = new net.createServer();

server.on('connection', (client) => {
    client.on('data', async (msg) => { //接收client发来的信息
        
          const data = msg.toString('utf-8')
          console.log("YYYY")
          console.log(data )
          console.log("xxxxx")
          dosomething();
    });
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions