[OpenDHT-Users] Help with gateway_test program

Kannaiyan Natesan gbpnkans at gmail.com
Sun Aug 20 04:14:47 PDT 2006


Actually that program is good for running one time.

You replace the snippet in the run_test of gateway_test to make it
more interactive.

    while(1) {

    printf("Enter a string: ");
    scanf("%s",value_val1);

    // Do a first put.

    for(first=0;first<20;first++)
        put_args.key[first] = first % 9;
    //random_key (put_args.key, sizeof (put_args.key));
    //printf("%s %d",put_args.key,sizeof(put_args.key));
    put_args.value.bamboo_value_val = value_val1;
    put_args.value.bamboo_value_len = sizeof (value_val1);
    do_put (clnt, &put_args);

    // Check that the data's there.

    memcpy (get_args.key, put_args.key, sizeof (get_args.key));



    while( 1 ) {
    get_result = do_get (clnt, &get_args);

    if (get_result->values.values_len <= 0) {
        printf ("Get failed: returned %d
values.\n",get_result->values.values_len);
        break;
    }

    printf("Values Length: %d\n",get_result->values.values_len);

    for(first=0;first<get_result->values.values_len; first++) {
        printf("Value[%d]:
%s\n",first,get_result->values.values_val[first].bamboo_value_val);
    }

    if( get_result->placemark.bamboo_placemark_len == 0 )
        break;

    get_args.placemark.bamboo_placemark_val =
        get_result->placemark.bamboo_placemark_val;
    get_args.placemark.bamboo_placemark_len =
        get_result->placemark.bamboo_placemark_len;

    }

    }


Enjoy.

Regards,
Kannaiyan


On 8/20/06, aliter05-mail at yahoo.co.in <aliter05-mail at yahoo.co.in> wrote:
>
> Hello opendht developers,
> I am a third year engineering student from IIT Delhi, India. I am using the
> gateway_test.C program to learn how to use opendht. I modified the program
> slightly so that i can store more than one user input values. So when the
> program runs, it first asks me for 5 key-value pairs and then retrives the
> values using their respective keys. Simple enough, however, I am facing the
> following problem:
> When the gateway_test program is running, I am able to retrieve the values i
> had just stored. But if i exit the program and then start it again, (say i
> dont put any key-value pairs this time - only want to retrieve the values
> stored earlier) I am not able to retrive the values stored in the previous
> execution of the program. What is the reason behind this ? How do I
> accomplish my goal ?
>
> If this question seems too simple for you, please bear with me because i am
> new to opendht.
> Thank you .
> VijaySai Patnaik
>
>
>  ________________________________
>  Here's a new way to find what you're looking for - Yahoo! Answers
>  Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get
> it NOW
>
>
> _______________________________________________
> OpenDHT-Users mailing list
> OpenDHT-Users at opendht.org
> http://opendht.org/cgi-bin/mailman/listinfo/opendht-users
>
>
>



More information about the OpenDHT-Users mailing list