title: Reading Data in C From Socket Until End Character
body: <p>EDIT: It has been proven in the comments that defining the length instead should produce the same results and would not use any significant extra data. If you are looking for a way to send data between machines running your program(s), sending the length is better than reading until a terminating character. BonzaiThePenguin has some very good points you should look at.</p>
  
  <p>But for educational purposes: I never found good example code that does this for standard C sockets that handles situations where the data is not all received in one packet, or multiple separate messages are contained within one packet. Simply calling recv repeatedly will not work in all cases.</p>
  
  <p>This is one of those questions where I've answered it myself below, but I'm not 100% confident in my response.</p>