int skt_send_sync_recv(int fd, const void *sbuf, size_t slen, void *rbuf, size_t rlen, int timeout) { skt_send(fd, sbuf, slen); skt_set_noblk(fd, 0); skt_recv(fd, rbuf, rlen); return 0; }
int rpc_send(struct rpc *r, const void *buf, size_t len) { int ret, head_size; struct rpc_packet *pkt = &r->packet; pkt->header.len = len; pkt->data = (void *)buf; head_size = sizeof(rpc_header_t); ret = skt_send(r->fd, (void *)&pkt->header, head_size); if (ret != head_size) { loge("skt_send failed!\n"); return -1; } ret = skt_send(r->fd, buf, len); if (ret != len) { loge("skt_send failed!\n"); return -1; } return ret; }
int rpc_send(struct rpc *r, const void *buf, size_t len) { int ret, head_size; struct rpc_packet *pkt = &r->send_pkt; update_rpc_timestamp(pkt); pkt->header.payload_len = len; pkt->payload = (void *)buf; head_size = sizeof(rpc_header_t); ret = skt_send(r->fd, (void *)&pkt->header, head_size); if (ret != head_size) { loge("skt_send failed!\n"); return -1; } ret = skt_send(r->fd, pkt->payload, pkt->header.payload_len); if (ret != pkt->header.payload_len) { loge("skt_send failed!\n"); return -1; } return (head_size + ret); }
static int tcp_write(struct protocol_ctx *sc, void *buf, int len) { struct tcp_ctx *c = sc->priv; return skt_send(c->fd, buf, len); }
int rpc_echo(struct rpc *r, const void *buf, size_t len) { return skt_send(r->fd, buf, len); }