While working on a donationware app I released some time ago, and monitoring its’ performance on a Ubuntu host, I noticed that TCPSocket communications would lag horribly behind. It took me some time to track down the issue after looking through the Real Studio forums, Mailing List, and various third-party websites for possible causes. In the end, I found a post on a mailing list archive where the author had experienced the same issue. The problem? The event loop isn’t polling the sockets as often as it should (and certainly not as often as it does on Windows or the Mac OS). Knowing this, the solution was quite simple: force the polling to happen.
On your window, let’s call it “wndMain”, add a timer that we’ll call “tmrPoll”. Set its mode to 0 and it’s interval to 50. In the “Open” event of wndMain, add the following code:
#if TargetLinux then tmrPoll.Mode = 2 #endif
Now, let’s go in to the “Action” event of tmrPoll, and add the following code (which is generally regarded as a no-no, but it works):
And there you go. My server app is now running perfectly with nearly 40 concurrent connections.