+int fio_net_send_cmd(int fd, uint16_t opcode, const char *buf, off_t size)
+{
+ struct fio_net_cmd *cmd;
+ size_t this_len;
+ int ret;
+
+ do {
+ this_len = size;
+ if (this_len > FIO_SERVER_MAX_PDU)
+ this_len = FIO_SERVER_MAX_PDU;
+
+ cmd = malloc(sizeof(*cmd) + this_len);
+
+ fio_init_net_cmd(cmd, opcode, buf, this_len);
+
+ if (this_len < size)
+ cmd->flags |= FIO_NET_CMD_F_MORE;
+
+ fio_net_cmd_crc(cmd);
+
+ ret = fio_send_data(fd, cmd, sizeof(*cmd) + this_len);
+ free(cmd);
+ size -= this_len;
+ buf += this_len;
+ } while (!ret && size);
+
+ return ret;
+}
+