int ServerMain(LPVOID pointerToObject) { minitialize(); AllocConsole() ; AttachConsole( GetCurrentProcessId() ) ; freopen( "CON", "w", stdout ) ; // Accept a client socket for (int sock=1; sock<1000; sock++) { ClientSocket = accept(ListenSocket, NULL, NULL); char sockprint[80]; char sockchar[4]; itoa(sock,sockchar,10); strcpy(sockprint,"Client "); strcat(sockprint,sockchar); strcat(sockprint," connected."); printm(sockprint); GoToXY(0,23); if (ClientSocket == INVALID_SOCKET) { std::cout<<"accept failed with error: "<<WSAGetLastError()<<"\n"; closesocket(ClientSocket); WSACleanup(); minitialize(); } client[sock].cs=ClientSocket; client[sock].con=true; client[sock].i=clientnumber; client[sock].client=sock; lastclient=clientnumber; hRecvThread = CreateThread(NULL,0,recvfunc,pointerToObject,0,&dwRecvThreadId); clientnumber++; currentclient=clientnumber; } while(true) { Sleep(1000000); } // shutdown the connection since we're done mshutdown(); return 0; }
void main(int argc, char **argv) { /*--- Add rng_type as the argument to the new interface ---*/ int rng_type; int seed, param, block_size, discard_blocks, use_blocks; /****************** Read and check Arguments ********************/ if(argc==8 ) /*--- increase argc by 1 ---*/ { argv++; rng_type = atoi(*argv++); /*--- get rng_type ---*/ seed = atoi(*argv++); param = atoi(*argv++); lattice_size = atoi(*argv++); block_size = atoi(*argv++); discard_blocks = atoi(*argv++); use_blocks = atoi(*argv++); check_arguments(lattice_size, block_size, discard_blocks, use_blocks); #ifdef PARALLEL printf("Wolff Algorithm with Parallel RNG\n"); #else printf("Wolff Algorithm with Serial RNG\n"); #endif printf("lattice_size = %d, block_size = %d, discard_blocks = %d, use_blocks = %d\n", lattice_size, block_size, discard_blocks, use_blocks); } else { printf("USAGE: %s rng_type seed param lattice_size block_size discard_blocks use_blocks\n", argv[0]); exit(-1); } minitialize(rng_type, seed, param, use_blocks); /* initalize data */ /************** 'Thermalize' system so that results are not influenced by the initial onditions *************/ thermalize(block_size, discard_blocks); /********** Perform the actual Wolff algorithm calculations *********/ wolff(block_size, use_blocks); }
/* MutexObjWrapper functions */ MutexObjWrapper::MutexObjWrapper(void) { minitialize(); mutexObj = new MutexObj(); }
/* EventObjWrapper functions */ EventObjWrapper::EventObjWrapper(void) { minitialize(); eventObj = new EventObj(); }