本文整理匯總了C++中TestApp::start方法的典型用法代碼示例。如果您正苦於以下問題:C++ TestApp::start方法的具體用法?C++ TestApp::start怎麽用?C++ TestApp::start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TestApp
的用法示例。
在下文中一共展示了TestApp::start方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: fork_clients
//.........這裏部分代碼省略.........
perror("recv_NAME");
exit(1);
}
CLIENT_NAME[numbytes_client] = '\0';
char client_name[100];
strcpy(client_name,CLIENT_NAME);
MY_TOKEN=nonce_name_hash(uint32_t(htonl(atoi(NONCE))), client_name);
//c<<"hash is ------------"<<hex<<MY_TOKEN<<endl;
string file_name= "stage"+STAGE+"."+(string)CLIENT_NAME+".out";
outfile_client.open(str_to_char(file_name));
outfile_client<<"client "<<CLIENT_NAME<<" created with hash "<<hex<<MY_TOKEN<<endl;
//outfile_client<<"received the host name from manager:"<<CLIENT_NAME<<endl;
// receiving the FP from manager
if ((numbytes_client = recv(sockfd_client, FP, sizeof FP, 0)) == -1)
{
perror("recvFP");
exit(1);
}
FP[numbytes_client] = '\0';
//outfile_client<<"received FP:"<<dec<<FP<<endl;
// receiving the FS from manager
if ((numbytes_client = recv(sockfd_client, FS, sizeof FS, 0)) == -1)
{
perror("recvFS");
exit(1);
}
FS[numbytes_client] = '\0';
//outfile_client<<"received FS:"<<FS<<endl;
//int client_nonce = atoi(buf_client);
////////////////////////////////////////////////////////////////////
// creating a UDP socket for triad messages- UDP_private
////////////////////////////////////////////////////////////////////
create_main_udp_port();
////////////////////////////////////////////////////////////////////
// creating a UDP socket for hello messages- UDP_hello
////////////////////////////////////////////////////////////////////
create_hello_udp_port();
create_lazy_udp_port();
//printf("DGRAM port is : %d\n",DGRAM_PORT);
//outfile_client<< "my udp port is : "<<dec<<DGRAM_PORT<<endl;
//////////////////////////////////////////////
// finding position in the ring
//////////////////////////////////////////////
if ((STAGE.compare("2")==0) || (STAGE.compare("3")==0))
{
position_in_ring();
}
else if((STAGE.compare("6")==0) || (STAGE.compare("7")==0))
{//cout<<" inside the right intializer"<<endl;
position_in_ring_FT();
}
////////////////////////////////////////////////////////////////////////////////////////////
// sending dgram port and NONCE+Sx to manager through tcp socket - sockfd_client
////////////////////////////////////////////////////////////////////////////////////////////
sprintf(buf,"%d",DGRAM_PORT);
if(send(sockfd_client, buf, sizeof(buf), 0) == -1)
perror("send");
//outfile_client<<"dgram port sent is:"<<dec<<DGRAM_PORT<<endl;
char q[100];
strcpy (q,NONCE);
strcat (q,client_name);
if(send(sockfd_client, q, sizeof(q), 0) == -1)
perror("send");
//outfile_client<<"concat nonce+Sx sent is:"<<dec<<q<<endl;
//////////////////////////////////////////////////////////////////////////
// SELECT between the TCP and UDP sockets
//////////////////////////////////////////////////////////////////////////
//SELECT();
TestApp *app;
app = new TestApp;
//Start the timers
app->start();
close(sockfd_client);
outfile_client.close();
//outfile_client.close();
exit(0); //once the child is done sending the info kill the child
} // end child code
} // end for loop
} // end function