I am currently migrating the server part of a Client/Server application from OpenVMS to Linux (RHEL). the communication is done via RPC. I now saw that the portmapper 'spreads' the assigned ports over the whole range instead of assigning one after the other (as it does in with OpenVMS).
I assign the ports by the following code (GNU-C):
(void)pmap_unset(server_nr, KOMVERS) ;
transp = svctcp_create(RPC_ANYSOCK, 0, 0) ;
if (transp == NULL)
{
fprintf(stderr, "cannot create tcp service.\n") ;
exit(EXIT_FAILURE) ;
}
if (!svc_register(transp, server_nr, KOMVERS, komprog_1, IPPROTO_TCP))
{
fprintf(stderr, "unable to register (%ld, tcp).\n",server_nr) ;
exit(EXIT_FAILURE) ;
}
server_nr is the number of the server program (starting from 800000000) used by the client to access the server. After starting several server processes, I get
... using rpcinfo
800000101 1 tcp 0.0.0.0.250.211 - unknown
800000102 1 tcp 0.0.0.0.250.211 - unknown
... using netstat
Proto Recv-Q Send-Q Local Address Foreign Adress State PID/Program
tcp 0 0 0.0.0.0:52414 0.0.0.0:* LISTEN 1604/Server01
tcp 0 0 0.0.0.0:25600 0.0.0.0:* LISTEN 1606/Server02
I would prefer that the port mapper always uses a defined port (my application is the only on the machine) for security reasons, but I could not find out how to do this. Can anybody help me?