Exemplo n.º 1
0
Arquivo: libskt.c Projeto: gozfree/src
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
Arquivo: tcp.c Projeto: gozfree/src
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);
}
Exemplo n.º 5
0
int rpc_echo(struct rpc *r, const void *buf, size_t len)
{
    return skt_send(r->fd, buf, len);
}