I am tried to understand the passive socket by tracing the code
http://merkez.ube.ege.edu.tr/~erciyes/ube528/passivesock.c
And I found that the following code
/* Map service name to port number */
if(pse = getservbyname(service, protocol)){
sin.sin_port = htons(ntohs((u_short)pse->s_port) + portbase);
}
else if((sin.sin_port = htons((u_short)atoi(service))) == 0){
errexit("can't get \"%s\" service entry\n", service);
}
I have some question about the htons(ntohs((u_short)pse->s_port) + portbase);
What is the portbase, I found the comment u_short portbase = 0; /* port base, for non-root servers */
but still know what it means?
I have googled it by 'passive socket portbase' but cannot find useful information.
Thx in advance.