added a utility function that just runs send(2) in a loop until all is sent