static int __ptcp_write(struct protocol_ctx *sc, void *buf, int len) { struct ptcp_ctx *c = sc->priv; #if 0 int res; int step = 1024; int left = len; void *p = buf; #endif #if 1 len = ptcp_send(c->ps, buf, len); usleep(200 * 1000); #else while (left > 0) { if (left < 1024) step = left; res = ptcp_send(c->ps, p, step); if (res == -1) { return res; } p += step; left -= step; usleep(300 * 1000); } #endif return len; }
int _ptcp_send(void *arg, void *buf, size_t len) { ptcp_socket_t *ps = (ptcp_socket_t *)arg; return ptcp_send(ps, buf, len); }
int p2p_send(struct p2p *p2p, void *buf, int len) { return ptcp_send(p2p->ps, buf, len); }