I am trying to make sure that every time I call the socket.send function my buffer is sent (flushed) to my server (which is in C using unix socket).
From my understa
There is no way to ensure the size of the data chunks that are sent. If you want to make sure that all the data that you want to send is send, you can close the connection:
self.sck.close()
Note also, that n = socket.send() returns the number of actual sent bytes. If you definitely want to send all data, you should use
self.sck.sendall()
or loop over the data sending:
while data:
n = self.sck.send(data)
data = data[n:]
(But that is roughly the same as sendall() ). If you want to receive the data in bigger chunks, you can increase the size of the buffer in recv(), but this only makes the possible chunk size bigger. There is no guaranty that the data arrives in these sizes.