static ssize_t tnt_net_writev(struct tnt_stream *s, struct iovec *iov, int count) { struct tnt_stream_net *sn = TNT_SNET_CAST(s); ssize_t rc = tnt_io_sendv(sn, iov, count); if (rc != -1) s->wrcnt++; return rc; }
int nb_mc_get(struct tnt_stream *t, char *key) { char buf[64]; int len = snprintf(buf, sizeof(buf), "get %s\r\n", key); struct iovec v[1]; v[0].iov_base = buf; v[0].iov_len = len; int r = tnt_io_sendv(TNT_SNET_CAST(t), v, 1); return (r < 0) ? -1 : 0; }
int nb_mc_set(struct tnt_stream *t, char *key, char *data, int data_size) { char buf[64]; int len = snprintf(buf, sizeof(buf), "set %s 0 0 %d\r\n", key, data_size); struct iovec v[3]; v[0].iov_base = buf; v[0].iov_len = len; v[1].iov_base = data; v[1].iov_len = data_size; v[2].iov_base = "\r\n"; v[2].iov_len = 2; int r = tnt_io_sendv(TNT_SNET_CAST(t), v, 3); tnt_flush(t); return (r < 0) ? -1 : 0; }