Multiple threads for multiple ports?

To start, I don’t know much about network programming ...

So, I have a program (process) that should listen on 3 ports ... Two are TCP and other UDP.

Two TCP ports will receive a large amount of data each time as often (maybe just every 5 minutes or as often as every 20 seconds). The third (UDP) port accepts persistent data. Now, does it make sense for them to listen to different topics?

For example, when I receive a large amount of data from one of the TCP ports, I do not want my UDP stream to be interrupted ... are these common problems for network programming?

Thanks guys, feel free to ask clarification questions if I don't understand.

I will use the Boost library for Windows if it has any support.

The EDIT: . After reading this again, I realized that I am not asking a specific question lol ... I guess I'm just looking for some thoughts / ideas / recommendations on this issue and how to manage multiple connections. Thanks

+3
source share
4 answers

In general, avoid threads if necessary. On a modern machine, you will get better performance using a single thread and using the I / O ready / complete functions. On Windows, this is the I / O completion port, on Mac OS X and FreeBSD: kqueue (2), on Solaris: the event ports on the Linux epic on VMS QIO. Etc.

In boost, this abstracts from boost :: asio.

, , - , , .

+5

, , .

, , . .

+2

-,

... ?

, .

-, , . , .

, , , , , . , .

+1

. . , 3, . , , , .

select()/poll()/epoll()/libevent/etc. Linux- epoll() . , , , , . ( , ), , .

, , , . select()/poll() - .

. C10K:

http://www.kegel.com/c10k.html

+1
source

Source: https://habr.com/ru/post/1718617/


All Articles