int main (int argc, char **argv){
	minstack_tcp *mt_listen;
	if(argc != 4)
		usage(argv[0]);

	signal(SIGABRT, stop);
	signal(SIGTERM, stop);
	signal(SIGINT, stop);

	printf("starting %s on the address %s port %d\n",argv[0],argv[1],atoi(argv[2]));
	mt_listen = minstack_tcp_init("The minstack client test");
	if(minstack_tcp_init_client(mt_listen,atoi(argv[2]),argv[1]))
	{
		printf("We could not initialized the client test...\n");
		return 0;
	}
	minstack_tcp_set_external_read_function(mt_listen,listenner);
	minstack_set_debug_level(MINSTACK_WARNING_LEVEL);
	minstack_tcp_start(mt_listen);
	usleep(100*1000);
	minstack_tcp_printf(mt_listen,"%s",argv[3]);
    usleep(2*1000*1000);
	printf("stopping %s\n",argv[0]);
	minstack_tcp_stop(mt_listen);
	minstack_tcp_uninit(mt_listen);
	return 0;
}
Exemplo n.º 2
0
int main (int argc, char **argv){
	minstack_tcp *mt_listen;
	if(argc != 5)
		usage(argv[0]);

	signal(SIGABRT, stop);
	signal(SIGTERM, stop);
	signal(SIGINT, stop);

	printf("Starting %s\n",argv[0]);
	printf("We are saying to %s to send videosupervision to %s:%d\n", argv[1],argv[2],atoi(argv[3]));
	mt_listen = minstack_tcp_init("The minstack client test");
	if(minstack_tcp_init_client(mt_listen,listenning_port,argv[1]))
	{
		printf("We could not initialized the client test...\n");
		return 0;
	}
	minstack_tcp_set_external_read_function(mt_listen,listenner);
	minstack_set_debug_level(MINSTACK_WARNING_LEVEL);
	minstack_tcp_start(mt_listen);
	usleep(100*1000);
    send_options(mt_listen,USER_AGENT_TAG,argv[1]);
    usleep(100*1000);
    send_describe(mt_listen,USER_AGENT_TAG,argv[1]);
    usleep(100*1000);
    if(!strcmp(argv[4],"play"))
    {
        send_play(mt_listen,USER_AGENT_TAG,argv[1],argv[2],atoi(argv[3]),"H264");
        printf("Should be playing Here !!!\n");
    }
    else
    {
        send_teardown(mt_listen,USER_AGENT_TAG,argv[1]);
        printf("Should be stopping Here !!!\n");
    }
    usleep(10*1000);
	printf("stopping %s\n",argv[0]);
	minstack_tcp_uninit(mt_listen);
	return 0;
}
Exemplo n.º 3
0
/**
 * \brief The simplest way to start a server with a special read function
 * \param nickname is the name given to the minstack_tcp could be NULL
 * \param port is the port where the client could try to connect
 * \param max_client_number is the maximum number of clients that could be connected
 * \param function is the function call when something is received
 * \return the minstack_tcp stack generated, NULL if something wrong happenned
 */
minstack_tcp *minstack_tcp_start_a_server_with_read_function(
        const char *nickname, int port, int max_client_number, void(*function)(
                int cid, const char *from, char *buffer, unsigned int buffer_size_returned)) {
    int retval;
    minstack_tcp *mt = minstack_tcp_init(nickname);
    if (mt == NULL)
        return NULL;
    retval = minstack_tcp_init_server(mt, port, max_client_number);
    if (retval) {
        minstack_tcp_uninit(mt);
        return NULL;
    }
    retval = minstack_tcp_set_external_read_function(mt, function);
    if (retval) {
        minstack_tcp_uninit(mt);
        return NULL;
    }
    retval = minstack_tcp_start(mt);
    if (retval) {
        minstack_tcp_uninit(mt);
        return NULL;
    }
    return mt;
}