Giter VIP home page Giter VIP logo

Comments (4)

xia-chu avatar xia-chu commented on September 28, 2024

udp connect is actually not very useful. It just sets the address of the other end, so you can call the write and send functions (without using sendto).

One udp port corresponds to one fd, so it can only correspond to one thread. Therefore, to improve the performance of udp, it is usually solved by using multiple udp ports.

udp connect 其实并没什么用 只是设置下对端的地址 这样可以调用write和send函数(而不用sendto).

一个udp端口对应一个fd,所以一般只能对应一条线程。所以要提高udp的性能,一般通过多个udp端口解决。

TRANS_BY_GITHUB_AI_ASSISTANT

from zltoolkit.

xia-chu avatar xia-chu commented on September 28, 2024

In a TcpServer, a tcp port has a listen fd. After receiving an accept event, it can create multiple peerfds.

This listen fd is monitored by multiple threads, and multiple threads can accept simultaneously. After a successful accept, there is a peerfd, which will be bound to the accept thread.

TcpServer中,一个tcp端口,有一个listen fd, 在收到accept事件后,能创建多个peerfd。
这个listen fd是多个线程监听的,可以多个线程同时accept,accept成功后有有一个peerfd,这个peerfd会 绑定到这条accept线程

TRANS_BY_GITHUB_AI_ASSISTANT

from zltoolkit.

xia-chu avatar xia-chu commented on September 28, 2024

In other words, a TCP server with a single port can utilize the performance of a multi-core CPU, but a UDP server with a single port can only utilize the performance of a single thread.

也就是说 tcp服务器单端口能发挥多核cpu的性能,但是udp单端口只能发挥单条线程的性能

TRANS_BY_GITHUB_AI_ASSISTANT

from zltoolkit.

wasphin avatar wasphin commented on September 28, 2024

Understood, thanks for the explanation.

了解了, 多谢解答.

TRANS_BY_GITHUB_AI_ASSISTANT

from zltoolkit.

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.