Can't set TCP_MAXSEG's value

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
 
J

Jack Klein

Hi all,
I am using Redhat9, and trying to change a tcp socket's maxseg.

[snip]

Ask this in a Linux group like It is not a C++ language question because the standard language has no
support for sockets or any type of networking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,473
Latest member
pioneertraining

Latest Threads

Top