int tclcommand_imd_print_check_connect(Tcl_Interp *interp) { /* handshaking */ if (vmdsock_selread(initsock, 0) > 0) { int32_t length; sock = vmdsock_accept(initsock); if (imd_handshake(sock)) { Tcl_AppendResult(interp, "IMD handshake failed. Wrong VMD version ?", (char *) NULL); vmdsock_destroy(sock); sock = 0; return (TCL_ERROR); } sleep(1); if ((vmdsock_selread(sock, 0) != 1) || (imd_recv_header(sock, &length) != IMD_GO)) { Tcl_AppendResult(interp, "No go from VMD. Wrong VMD version ?", (char *) NULL); vmdsock_destroy(sock); sock = 0; return (TCL_ERROR); } sleep(1); } return (TCL_OK); }
void IMD::connect(){ if(comm.Get_rank()==0) { if(wait && clientsock==NULL) fprintf(stderr,"Waiting for IMD connection on %s:%d...\n", host.c_str(), port); do{ if (vmdsock_selread(sock,00) > 0) { clientsock = vmdsock_accept(sock); if (imd_handshake(clientsock)) { clientsock = NULL; }; sleep(1); int length; if(clientsock){ if (vmdsock_selread(clientsock, 0) != 1 || imd_recv_header(clientsock, &length) != IMD_GO) { clientsock = NULL; } } } } while(wait && clientsock==NULL); connected=(clientsock!=NULL); int c=connected; comm.Bcast(&c,1,0); } else { int c; comm.Bcast(&c,1,0); connected=c; } }