我正在尝试使用以下方法设置每个用户的最大渗透量:
time_t start;
char buf[BUFSIZ], *command, content;
int n,i;
FILE *fptr;
start = time(0);
(void) pthread_mutex_lock(&stats.st_mutex);
stats.st_concount++;
(void) pthread_mutex_unlock(&stats.st_mutex);
while (1) {
bzero(buf, BUFSIZ);
n = recv(fd, buf, BUFSIZ, 0);
if (n < 0){
errexit("echo read: %s\n", strerror(errno));
}
else{
printf("The client message: %s\n",buf);
}
strtok_r (buf, " ", &command);
printf("%s\n", buf);
printf("%s\n",command);
//char filename[100], c;
// printf("Enter the filename to open \n");
// scanf("%s", command);
// Open file
fptr = fopen(command, "r");
if (fptr == NULL)
{
printf("Cannot open file \n");
exit(0);
}
// Read contents from file
content = fgetc(fptr);
while (content != EOF)
{
printf ("%c", content);
content = fgetc(fptr);
}
它在本地JBoss(1个实例)上可以正常工作,但是在2个实例的更高环境中,它无法运行,因为它无法跟踪2个实例之间的用户会话。有办法解决吗?