Where to start with multi-threaded programming using C ++?

I am trying to implement my own IRC client as a personal proejct, and I realized that I need a way to read and write from the socket at the same time. I realized that I can have a read stream that reads from the socket in the background and puts the data in the queue, and I can have another stream that writes data from the queue to the socket. However, I do not know how to start with multi-threaded programming or how to do it using C ++. Where am I going from here?

+3
source share
5 answers

For C ++ streams, boost :: thread (which is the foundation for the upcoming std::thread) is the best way. However, although threads may be the right solution for your particular case, I just wanted to throw it away where select and non-blocking sockets are a common approach to strip read / write and write multiple sockets without the need for threads. The boost :: asio library wraps the functionality of selected and non-blocking sockets in a cross-platform form in C ++.

+10
source

C * nix, , Beej Guide to Network Programming. " -, ".

, , .

+5

Qt Threading. . , LGPL . .

, ,

+3

POCO. -, , . . , .

0

ACE. (* nix, Windows ..): BSD, , , .. - (. ACE_OS ACE).

, (ACE_Reactor ), BSD (, send, recv, close, - IRC)

, boost - , ( wxWidgets, qt - ).

: , . , .

When accessing network connectivity, I find that what you want to do is easily achievable in a single-threaded application (ACE_Reactor helps you a lot here, but you can use the BSD socket functions). Understand how sockets work first, and then - if you want to - understand how the reactor uses sockets in its network application templates ( ACE_Reactor works with ACE_Event_Handler objects ).

Hope this helps!

0
source

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


All Articles