I'm trying to understand how local sockets (Unix domain socket) works, specifically how to use them with QT. It is my understanding that Unix domain socket is always reliable and no data is lost. Looking at these examples these are the steps (making it simple), considering a Server (producer) and a Client (consumer)..
- A qLocalServer (on the Server) create a socket, bind it to a known location and listen for incoming connections..
- A qLocalSocket (on the client) connect to the known location. On the server connection is accepted.
- Server can send data to the socket using
write
method (of theqLocalSocket
instance returned byqLocalServer->nextPendingConnection()
)
When the socket buffer is full, any write by the server is blocked as soon as the client read from the socket and free the socket buffer. This is the part I don't understand: suppose the socket buffer is full and the server keeps writing .. where all these data are stored and how to control the data structure holding these data? Is there any way to discard these data? Imagine a server that produce data 20 times/second and a client that consume 1 time/second, I want to drop all data in bewtween (better real time data than ALL the data in my use case).