As a complement to David Schwartz proper answer:
Depending on underlying protocolif the socket is non-blocking,or not, it is NOT guaranteed that a single send will actually send all data. You must check return value and might have to call send again (with correct buffer offsets).
For instance if you want to send 10 bytes of data (len=10), you call send(sock, buf, len, 0). However lets say it only manages to send 5 bytes, then send(..) will return 5, meaning that you will have to call it again later like send(sock, (buf + 5), (len - 5), 0). Meaning, skip first five bytes in buffer, they're already sent, and withdraw five bytes from the total number of bytes (len) we want to send.
You are best suited to do it in a while loop, somethinglike while(sent_bytes < len) (and ofc check for -1 and 0 return values). Note alsoNote that I used parenthesis to make it easier to read only, and it assumes that buf is a pointer to 1 byte type.)