#include #include #include "globus_xio.h" #include "globus_xio_gsi.h" int main( int argc, char * argv[]) { globus_xio_driver_t tcp_driver; globus_xio_driver_t gsi_driver; globus_xio_stack_t stack; globus_xio_handle_t handle; globus_xio_attr_t attr; globus_size_t nbytes; char * contact_string = NULL; char incoming[256]; /* grab the host:port combination from command line */ contact_string = argv[1]; /* activate the XIO module */ globus_module_activate(GLOBUS_XIO_MODULE); /* load the TCP and GSI drivers */ globus_xio_driver_load("tcp", &tcp_driver); globus_xio_driver_load("gsi", &gsi_driver); /* create a driver stack and load it first with the TCP driver and then the GSI driver */ globus_xio_stack_init(&stack, NULL); globus_xio_stack_push_driver(stack, tcp_driver); globus_xio_stack_push_driver(stack, gsi_driver); /* create a handle */ globus_xio_handle_create(&handle, stack); /* we need an attribute to decorate the handle */ globus_xio_attr_init(&attr); /* because the pyGlobus LDRdataFindServer uses a clear channel and by default the XIO GSI driver does not, we need to set it directly and then decorate the handle */ globus_xio_attr_cntl( attr, gsi_driver, GLOBUS_XIO_GSI_SET_PROTECTION_LEVEL, GLOBUS_XIO_GSI_PROTECTION_LEVEL_NONE ); /* connect to the server using the decorated handle */ globus_xio_open(handle, contact_string, attr); /* send 5 bytes 'P I N G \0' to ping the server */ globus_xio_write(handle, "PING\0", 5 , 5, &nbytes, NULL); /* read the incoming message from the server */ globus_xio_read(handle, incoming, sizeof(incoming) - 1, sizeof(incoming) - 1, &nbytes, NULL); /* first byte is return value followed by null byte and then the message back from the server */ if(nbytes > 0){ fprintf(stdout, "Return value from server: %s\n", incoming); fprintf(stdout, "Message from server: %s\n", incoming + 2); } /* clean up */ globus_xio_close(handle, NULL); globus_module_deactivate_all(); return 0; }