Synchronize access to tcp buffer

Needed because flushing on disconnect