Quote Originally Posted by wysota View Post
It may work but is still an ugly solution. If you only want to make sure you have a single instance of the application, you can avoid sockets. If you want your applications on a local machine to communicate, you could come up with a better solution too. Depending on high-numbered sockets is a risk, because there is no way telling if no other app (for example some ftp client or server) doesn't use the same socket.
Maybe ugly but better than nothing. Besides socket corruption is highly improbable since localhost is used and the port is dynamically assigned by Qt through the server classes (QTcpServer or QUdpServer)

Quote Originally Posted by wysota View Post
Why do you need a QSemaphore here? Is your app accessing the socket from multiple threads?
The semaphore was just used as a convinient counter providing possibilities of extension to multithreaded approach...