I am encountering some performance issues with my SERVER<->CLIENTs tcp communication and I think it is related to how I perform my communication.
Specifically - the way it works today - I have tried the following two approaches:
1- Foreach Client the main form launches (create and start) a thread per client (so many threads), each thread performs the tcpclient connection, sends the data, and then close.
2- Main thread launches a single thread (create and start) which will loop through the list of clients (tcpclient connection, send data, close) and send the data
In both cases I use TCPClient & NetworkStream to perform the actual transfer (so create a TCPClient to the Client with the corresponding IP and PORT and then use the Network Stream to send the data itself).
As mentioned this seems to work a little slow so I was trying to look at ways of improving the code (as there is a LOT of information passed between the server and the 1-100 clients depending)...
So I did some reading and found the concepts of "BROADCAST" and "MULTICAST" - but I have no clue if these can apply to my situation (tcp) ...?
Therefore I am here asking for advice or confirmation - if either option (1) or (2) (mentioned above) are the CORRECT way of hanlding the situaton then I know I am on the right path.
But I thought there must be a type of concept where I can just BROADCAST or MULTICAST the data to a single TcpClient (or socket, or something) that would handle sending the information to all clients automatically.
Wouldn't that be the CORRECT approach? How is this typically resolved?
I am looking for any kind of advice on how to proceed...
Any ideas, hints, and help would be greatly appreciated, thanks
Specifically - the way it works today - I have tried the following two approaches:
1- Foreach Client the main form launches (create and start) a thread per client (so many threads), each thread performs the tcpclient connection, sends the data, and then close.
2- Main thread launches a single thread (create and start) which will loop through the list of clients (tcpclient connection, send data, close) and send the data
In both cases I use TCPClient & NetworkStream to perform the actual transfer (so create a TCPClient to the Client with the corresponding IP and PORT and then use the Network Stream to send the data itself).
As mentioned this seems to work a little slow so I was trying to look at ways of improving the code (as there is a LOT of information passed between the server and the 1-100 clients depending)...
So I did some reading and found the concepts of "BROADCAST" and "MULTICAST" - but I have no clue if these can apply to my situation (tcp) ...?
Therefore I am here asking for advice or confirmation - if either option (1) or (2) (mentioned above) are the CORRECT way of hanlding the situaton then I know I am on the right path.
But I thought there must be a type of concept where I can just BROADCAST or MULTICAST the data to a single TcpClient (or socket, or something) that would handle sending the information to all clients automatically.
Wouldn't that be the CORRECT approach? How is this typically resolved?
I am looking for any kind of advice on how to proceed...
Any ideas, hints, and help would be greatly appreciated, thanks