S
Shin
Hi all,
I am using Redhat9, and trying to change a tcp socket's maxseg.
Here is part of my code:
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
perror(NULL);
exit(-1);
}
int oldmaxseg = 0;
int size = sizeof(oldmaxseg);
if(getsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &oldmaxseg,
&size) == -1){
perror(NULL);
exit(-1);
}
printf("oldmaxseg:%d size:%d\n", oldmaxseg, size);
int maxseg = 534;
if(setsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &maxseg,
sizeof(maxseg)) == -1){
perror(NULL);
exit(-1);
}
if(getsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &oldmaxseg,
&size) == -1){
perror(NULL);
exit(-1);
}
printf("oldmaxseg:%d size:%d\n", oldmaxseg, size);
and the code prints:
oldmaxseg:536 size:4
oldmaxseg:536 size:4
It's still 536, not 534.
It seems you can't change the maxseg in some platform.
Is it true on linux? If not, how can I change the value?
Thanks
Shin
I am using Redhat9, and trying to change a tcp socket's maxseg.
Here is part of my code:
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
perror(NULL);
exit(-1);
}
int oldmaxseg = 0;
int size = sizeof(oldmaxseg);
if(getsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &oldmaxseg,
&size) == -1){
perror(NULL);
exit(-1);
}
printf("oldmaxseg:%d size:%d\n", oldmaxseg, size);
int maxseg = 534;
if(setsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &maxseg,
sizeof(maxseg)) == -1){
perror(NULL);
exit(-1);
}
if(getsockopt(sockfd, SOL_TCP, TCP_MAXSEG, &oldmaxseg,
&size) == -1){
perror(NULL);
exit(-1);
}
printf("oldmaxseg:%d size:%d\n", oldmaxseg, size);
and the code prints:
oldmaxseg:536 size:4
oldmaxseg:536 size:4
It's still 536, not 534.
It seems you can't change the maxseg in some platform.
Is it true on linux? If not, how can I change the value?
Thanks
Shin