Home > other >  The socket communication
The socket communication

Time:11-01

How to use the TCP implementation will generate the server data real-time transmission to other clients in the same local area network? Using multi-threaded or thread pool? Server and real-time generate new data in the main program, is to generate new data while the data to multiple clients, give a great god,

CodePudding user response:

Saw your problem, use a multi-threaded or thread pool is not the key to realize the function, you server that produce data while sending data, should be the typical producer consumer model, so the problem is transferred to the model, can find some solution to handle the pattern to the net, there are a lot of, there is always a suitable for you,

CodePudding user response:

Look at your choice

CodePudding user response:

Mutual exclusion can be finished through the semaphore

CodePudding user response:

1. If from efficiency consideration, this kind of circumstance is not recommended to open a thread, you can directly in the main program data will be sent to the corresponding client, it has better real-time performance,
2. So to consider, the server to start, after listening to a port, after client connection, to have the data server, invoke sendto directly sent to the client,
In so doing, both in efficiency and real-time performance is good,

CodePudding user response:

reference 4 floor chj4129 response:
1. If from efficiency consideration, this kind of circumstance is not recommended to open a thread, can be directly in the main program data will be sent to the corresponding client, it has better real-time performance,
2. So to consider, the server to start, after listening to a port, after client connection, to have the data server, invoke sendto directly sent to the client,
In so doing, both in efficiency and real-time performance is good,
hello, excuse me, if you don't know how to monitor LAN computer interaction between IP?
  • Related