splitted write and flush in socket