Note that there are some explanatory texts on larger screens.

plurals
  1. POx number of threads sending data to Server for displaying output on GUI
    primarykey
    data
    text
    <p>I have developed a single server/multiple client TCP Application.</p> <p>The client consists of x number of threads each thread doing processing on its own data and then sending the data over TCP socket to the Server for displaying.</p> <p>The Server is basically a GUI having a window. Server receves data from the client and displays it.</p> <p>Now, the problem is that since there are 40 threads inside the client and each thread wants to send data, how can I achieve this using one connected socket?</p> <p><strong>My Suggestion:</strong></p> <p>My approach was to create a data structure inside each of the 40 threads in which data to be sent will be maintained. A separate Send Thread with one connected socket on client side is then created. This thread will read data from data structure of first thread, send it over the socket and then read the data from second thread and so on. </p> <p><strong>Confusions:</strong></p> <p>but I am not sure how would this be implemented as I am new to all this? :( What if a thread is writing to data structure and the Send Thread tries to read the data at the same time. I am familiar with mutex, critical section etc but that sounds too complex for my simple application.</p> <p>Any other suggestions/comments other than my own suggestion are welcome. If you think my own approach is correct then please help me solving my confusions that I mentioned above.</p> <p>Thanks a lot in advance :)</p> <p><strong>Edit:</strong></p> <p>Can I put I timer on Send Thread and after a specific time the Send Thread suspends thread#1(so that it can access its data structure without any synchronization issues), reads data from its data structure, sends it over the tcp Socket, and resumes Thread#1 back, then it suspends Thread#2, reads data from its data structure, sends it over the tcp Socket, and resumes Thread#2 back and so on.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload