int main(int argc, char**argv) { if(argc < 4) { printf("Exiting. Not all parameters supplied, expected callback port, application path, and gdb port.\n"); exit(0); } int callbackPort = atoi(argv[1]); char* applicationPath = argv[2]; int gdbPort = atoi(argv[3]); //Wait for a connection from the client sem_init(&quitingSemaphore, 0, 0); pthread_t stdInThreadId, callBackThread1Id, callBackThread2Id; pthread_create(&stdInThreadId, NULL, (void *)StdInThread, NULL); pthread_create(&callBackThread1Id, NULL, (void *)CallBackThread1, &callbackPort); pthread_create(&callBackThread2Id, NULL, (void *)CallBackThread2, &gdbPort); char* localAddress = (char*)malloc(50*sizeof(char)); GetPrimaryIp(localAddress, 50) ; char applicationCommandLine[255]; sprintf(applicationCommandLine, "%s %s %d %s %d", applicationPath, localAddress, callbackPort, applicationPath, gdbPort); _mpiFD = popen(applicationCommandLine, "w"); sem_wait(&quitingSemaphore); return 0; }
int poke(std::string ip) { /*int mysocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); struct sockaddr_in sip; memset(&sip, '0', sizeof (sip)); sip.sin_family = AF_INET; sip.sin_port = htons(80); if (inet_pton(AF_INET, ip.c_str(), &sip.sin_addr) <= 0) { return -1; } return connect(mysocket, (sockaddr*) & sip, sizeof (sip));*/ if (debug == 1) { std::cout << "\n" + getTime() + " poking " + ip + "...."; fflush(stdout); } ip = GetPrimaryIp(); if (debug == 1) { std::cout << "with ipadress: " + ip + "\n"; fflush(stdout); } if (ip.length() == 0) { return 1; } else { return 0; } }