Ensured flush and close in every Java buffer created from socket