int getIP() { SocketTCP myTCP; char buf[40]; unsigned int n = 0; myTCP.Open(WIJET2_PORT, htonl(INADDR_LOOPBACK)); strcpy(buf, "AskIP"); if (myTCP.Send(buf, strlen(buf) +1) > 0) { if (myTCP.Recv(buf, 40) > 0) { sscanf(buf, "%u", &n); } } return n; }
void* startClient(void *ma) { int rtn; char buffer[125], cmd[250]; SocketTCP *myClient = ((myArgs*)ma)->tcp; char *IP = ((myArgs*)ma)->ip; myClient->SetRcvTime(5000); rtn = myClient->Recv(buffer, 250); if (rtn > 0) { buffer[rtn] = 0; if (strstr(buffer,":")) // full mrl sprintf(cmd, "%s %s\n", myXine, buffer); else sprintf(cmd, "%s tcp://%s:%s\n", myXine, IP, buffer); fprintf(stderr, cmd); system(cmd); } delete myClient; printf("Done \n"); pthread_exit(0); }