These are chat archives for IndySockets/Indy

10th
Aug 2016
fan_tangshan
@sainimu78
Aug 10 2016 05:52

What Is wrong in this implementation?

In the client, I start a receive thread:
--the receive thread in the client:
----TIdTCPClient.IoHandler.ReadBytes
in the server:
--OnExcute:
----AContext.Connection.IoHandler.ReadBytes
If I first start the test transferring of the client sending data of < 80000 bytes to the server 10000 times and then do the same test reverse of the server sending to the client, there is nothing abnormal.
But if I first start the test of the server sending to the client and then the transferring speed becomes very low when do the test of the client sending to the server.

Remy Lebeau
@rlebeau
Aug 10 2016 16:19
I can't answer that without seeing your actual code
fan_tangshan
@sainimu78
Aug 10 2016 18:07
The test is one app sends data in size of < 7kb 100000 times to the other one.
If I never click the Server Send button to start the test of the server sending to the client and just do test the client to the server, it takes about 40~50 seconds in every test.
But if I click the Server Send once, the test of the client to the server sending will take apparently longer time than before.
QQ图片20160811020720.png
Here is the common read write procedure
blob
fan_tangshan
@sainimu78
Aug 10 2016 18:13
The server
blob
The client
blob
fan_tangshan
@sainimu78
Aug 10 2016 18:21
So simple test it is, I believe you'd tested it at the very beginning
Remy Lebeau
@rlebeau
Aug 10 2016 20:27
well, it kind of makes sense, if you take into account that the client code is single-threaded but the server code is multi-threaded, so you are likely getting task switches during the server-to-client sending that are slowing it down compared to the client-to-server sending. Remember, TIdTCPServer runs each client in its own worker thread. Even if there is only 1 client connected, there are still other threads running (the main UI thread, the server's listening thread, etc) that the OS has to service in a timely manner.