From: Daniel KouĊ™il Date: Tue, 31 Jan 2012 13:56:32 +0000 (+0000) Subject: print out the identity of the client X-Git-Tag: glite-jobid-api-c_R_2_1_0_2~19 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=b2a5796f761e6a7856005b90be393e15052303a1;p=jra1mw.git print out the identity of the client --- diff --git a/emi.canl.canl-c/examples/canl_sample_server.c b/emi.canl.canl-c/examples/canl_sample_server.c index 6048add..1e3c5e5 100644 --- a/emi.canl.canl-c/examples/canl_sample_server.c +++ b/emi.canl.canl-c/examples/canl_sample_server.c @@ -22,6 +22,8 @@ int main(int argc, char *argv[]) char buf[BUF_LEN]; int buf_len = 0; struct timeval timeout; + canl_principal princ = NULL; + char *name = NULL; while ((opt = getopt(argc, argv, "hp:c:k:")) != -1) { switch (opt) { @@ -136,13 +138,17 @@ int main(int argc, char *argv[]) /* canl_create_io_handler has to be called for my_io_h*/ /* TODO timeout in this function? and select around it*/ - err = canl_io_accept(my_ctx, my_io_h, new_fd, s_addr, 0, NULL, &timeout); + err = canl_io_accept(my_ctx, my_io_h, new_fd, s_addr, 0, &princ, &timeout); if (err) { printf("[SERVER] connection cannot be established: %s\n", canl_get_error_message(my_ctx)); goto end; } - printf("[SERVER] connection established\n"); + + err = canl_princ_name(my_ctx, princ, &name); + printf("[SERVER] connection established with %s\n", name); + free(name); + canl_princ_free(my_ctx, princ); strncpy(buf, "This is a testing message to send", sizeof(buf)); buf_len = strlen(buf) + 1;