uot;},*p = NULL;
char Msg[1024] = {""};
int iLen = 128;
MH MsgHead,*MsHe = NULL;
for (i = 0; i < num; i )
{
memset(Msg,0x00,sizeof(Msg));
memset(buf,0x00,sizeof(buf));
p = Msg;
//sleep(1);
sprintf(buf,"string%d-string%d-string%d-string%d-string%d",i 1,i 1,i 1,i 1,i 1);
MsgHead.BL[0] = (unsigned char)(strlen(buf) / 256 /256 /256);
MsgHead.BL[1] = (unsigned char)(strlen(buf) / 256 /256 );
MsgHead.BL[2] = (unsigned char)(strlen(buf) / 256 );
}
else
{
printf("connect to server failed!n");
return NULL;
}
//sleep(10);
close(tcpfd);
printf("nclient exit!nn");
return NULL;
}
int main(int argc,char **argv)
{
int num = 0,i = 0,sendrec = 0;
pthread_t tid;
if (argc == 1)
{
num = 5;
}
else
{
for (i = 0; i < strlen(argv[1]); i )
{
if (!isdigit(argv[1][i]))
{
printf("please added a number stringn!");
return 0;
}
}
num = atoi(argv[1]);
if (0 >= num || 65536 < num)
{
num = 5;
}
}
printf("send %d recordn",num);
sendrec = num;
for (i = 0; i < 5; i )
{
sendrec *= (i 1);
pthread_create(&tid,NULL,execute,(void *)&sendrec);
sleep(1);
sendrec = num;
}
for (i = 0; i < 5; i )
{
pthread_join(tid,NULL);
}
return 0;
}
|