示例#1
0
文件: ruby_xio.c 项目: tniuli/xio
static VALUE rb_sp_listen (VALUE self, VALUE eid, VALUE sockaddr)
{
	int _eid = FIX2INT (eid);
	const char *_sockaddr = RSTRING (sockaddr)->ptr;

	return INT2FIX (sp_listen (_eid, _sockaddr) );
}
示例#2
0
文件: thr_recver.c 项目: proxyio/xio
int main(int argc, char** argv) {
    int i;
    int eid;
    int count;
    int size;
    char* ubuf;
    int thr;
    double mbs;
    uint64_t st, lt;

    if (argc < 3) {
        printf("usage: thr_recver <bind-to> <msg-count>\n");
        return 0;
    }

    count = atoi(argv[2]);
    BUG_ON((eid = sp_endpoint(SP_REQREP, SP_REP)) < 0);
    BUG_ON(sp_listen(eid, argv[1]) < 0);

    BUG_ON(sp_recv(eid, &ubuf) != 0);
    size = 0;
    st = gettimeofms();

    while (count > 0) {
        BUG_ON(sp_recv(eid, &ubuf) != 0);
        count--;
        size += usize(ubuf);

        if (count) {
            ufree(ubuf);
        } else {
            BUG_ON(sp_send(eid, ubuf) != 0);
        }
    }

    lt = gettimeofms();

    thr = atoi(argv[2]) * 1000 / (lt - st);
    mbs = (double)(size * 8 / (lt - st)) / 1024;

    printf("message size: %d [B]\n", size);
    printf("throughput: %d [msg/s]\n", thr);
    printf("throughput: %.3f [Mb/s]\n", mbs);

    sp_close(eid);
    return 0;
}
示例#3
0
int main (int argc, char **argv)
{
	int i;
	int eid;
	char *ubuf;

	if (argc < 2) {
		printf ("usage: lat_recver <bind-to>\n");
		return 0;
	}
	BUG_ON ((eid = sp_endpoint (SP_REQREP, SP_REP)) < 0);
	BUG_ON (sp_listen (eid, argv[1]) < 0);

	while (1) {
		BUG_ON (sp_recv (eid, &ubuf) != 0);
		BUG_ON (sp_send (eid, ubuf));
	}
	sp_close (eid);
	return 0;
}