Giter VIP home page Giter VIP logo

Comments (16)

grasslog avatar grasslog commented on May 17, 2024 1

你们好,请问一下,我不太理解buffer缓冲。tcp的一方发送数据包,接收方接收到数据包,假设数据没有一次性读(read)完那么剩下的数据就无法处理吗?(tcp内核不是提供了内核缓冲区吗,为什么用户态还需要缓冲区)大佬,求解答

from webserver.

linyacool avatar linyacool commented on May 17, 2024

是指在哪里提供啊?

from webserver.

liushengxi13689209566 avatar liushengxi13689209566 commented on May 17, 2024

非阻塞IO应该都有Buffer作为缓冲.假如所到来的数据没有一次性读取完,那么剩下的数据您这里是如何处理的呐? muduo也是有 Buffer 缓冲的啊

from webserver.

linyacool avatar linyacool commented on May 17, 2024

有的,我直接用了个string来缓冲了

from webserver.

liushengxi13689209566 avatar liushengxi13689209566 commented on May 17, 2024

恩恩,明白了.我也写了一个这个项目,准备在你这里汲取一些精华.在你这个项目里加个配置文件和支持动态文件的功能吧,感觉这样会更好一点.

from webserver.

grasslog avatar grasslog commented on May 17, 2024

你们好,请问一下,我不太理解buffer缓冲。tcp的一方发送数据包,接收方接收到数据包,假设数据没有一次性读(read)完那么剩下的数据就无法处理吗?(tcp内核不是提供了内核缓冲区吗,为什么用户态还需要缓冲区)大佬,求解答

from webserver.

linyacool avatar linyacool commented on May 17, 2024

恩恩,明白了.我也写了一个这个项目,准备在你这里汲取一些精华.在你这个项目里加个配置文件和支持动态文件的功能吧,感觉这样会更好一点.

恩,确实

恩恩,明白了.我也写了一个这个项目,准备在你这里汲取一些精华.在你这个项目里加个配置文件和支持动态文件的功能吧,感觉这样会更好一点.

可以做的事情很多的,我只做到这一步了。。

from webserver.

linyacool avatar linyacool commented on May 17, 2024

你们好,请问一下,我不太理解buffer缓冲。tcp的一方发送数据包,接收方接收到数据包,假设数据没有一次性读(read)完那么剩下的数据就无法处理吗?(tcp内核不是提供了内核缓冲区吗,为什么用户态还需要缓冲区)大佬,求解答

因为tcp是基于字节流的协议,内核没有能力解析你的字节流,只能在用户态自己解析。

举个例子,A给B发 surprise
B内核态接受sur结束了,用户态从内核读到sur,什么也做不了,因为这不是一个完整的消息,好吧,下次继续读,读到prise,哦,这是另外一个单词了。
正确的做法就是我读到sur,我不明白是什么意思,我存起来,下次读到prise,组合起来,我才明白,原来是surprise的意思

from webserver.

grasslog avatar grasslog commented on May 17, 2024

感谢博主大大,我懂了

from webserver.

grasslog avatar grasslog commented on May 17, 2024

请问一下,如果要主动关闭连接,如何保证对方已经收到全部数据?

from webserver.

grasslog avatar grasslog commented on May 17, 2024

如何设计并使用缓冲区?有没有什么设计上的可借鉴之处?

from webserver.

linyacool avatar linyacool commented on May 17, 2024

请问一下,如果要主动关闭连接,如何保证对方已经收到全部数据?

保证不了的,发完就行了

from webserver.

linyacool avatar linyacool commented on May 17, 2024

如何设计并使用缓冲区?有没有什么设计上的可借鉴之处?

这个可以看一下陈硕的那本书<Linux多线程服务端编程>

from webserver.

grasslog avatar grasslog commented on May 17, 2024

嗯嗯,感谢博主

from webserver.

lixuhao avatar lixuhao commented on May 17, 2024

博主,你这个运行服务器是在上层生成的build/release目录下运行服务器的吗
就是在这个目录下,运行 ./WebServer -t 线程数目 -l 生成的日志所在的目录 -p 端口号

from webserver.

linyacool avatar linyacool commented on May 17, 2024

@lixuhao 再进几层找到可执行文件

from webserver.

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.