set buffering and write to socket