S
S
Sazoks2020-09-02 11:32:30
Qt
Sazoks, 2020-09-02 11:32:30

Is it ok to create multiple sockets on the same handle?

I have multiple threads. Each of them can send a message. This message needs to be sent to other clients via their sockets.
I did this: in the space where the threads themselves are stored, I store their descriptors in a special array. Then, when a message comes from someone, I call the method of sending this message to other sockets, namely, I create sockets in a loop according to these same descriptors stored in the shared space, and already through this socket created in this thread, I try to send a message, but in the end it gives me an error:
QSocketNotifier: Multiple socket notifiers for same socket 972 and type Read
and the program crashes ... It gives me exactly at the place where I set the descriptor.
Tell me, please, what is the error of my judgments?
When connecting a client and allocating a thread, I do this: I take the next connection, take the socket and pass it to the object, which then moveToThread ().
But for some reason it doesn't work here.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question