コード例 #1
0
ファイル: socket.c プロジェクト: Ugnis/Far-NetBox
/* Test a simple read. */
static int single_read(void)
{
    ne_socket *sock;
    DECL(hello, STR);

    CALL(begin(&sock, serve_sstring, &hello));
    CALL(read_expect(sock, STR, strlen(STR)));
    CALL(expect_close(sock));
    CALL(good_close(sock));

    return await_server();
}
コード例 #2
0
ファイル: socket.c プロジェクト: Ugnis/Far-NetBox
/* Test lots of 1-byte reads. */
static int small_reads(void)
{
    ne_socket *sock;
    char *pnt;
    DECL(hello, STR);

    CALL(begin(&sock, serve_sstring, &hello));

    /* read the string byte-by-byte. */
    for (pnt = hello.data; *pnt; pnt++) {
	CALL(read_expect(sock, pnt, 1));
    }

    return finish(sock, 1);
}
コード例 #3
0
ファイル: muxpect.c プロジェクト: gitpan/mon-app
/*
 * main
 */
int
main (int argc, char **argv)
{
    char fname[200], errbuf[100];
    chat_sess_t *sess;
    int c, help;
    unsigned short port;
    
    help = 0;
    debug = 0;
    memset (fname, 0, sizeof (fname));
    optind = 0;
    port = 0;

    while ((c = getopt (argc, argv, "dhf:p:")) != EOF)
    {
	switch (c) {
	    case 'h':
		help++;
		break;
	    case 'd':
		debug++;
		break;
	    case 'f':
		strncpy (fname, optarg, sizeof(fname));
		break;
	    case 'p':
		port = (unsigned short) strtol (optarg, (char **)NULL, 10);
		break;
	}
    }
    
    if (help)
	usage();
    
    if (fname[0] == '\0')
	usage();

    /*
     * read config file
     */
    sess = read_expect (fname);

    if (sess == NULL)
    {
	fprintf (stderr, "could not read\n");
	exit (1);
    }
    
    if (debug)
	dump_chat_sess (sess);

    if (setup_muxconn_struct (argv,
		optind,
		sess,
		port,
		errbuf,
		sizeof(errbuf)) == NULL)
    {
	printf ("could not setup sessions: %s\n", errbuf);
	exit (-1);
    }

    exit (0);
}