I have a legacy source file which describes the protocol to be used for RPC in a file with extension .x file which is fed to rpcgen to generate the necessary stub files for the protocol. However, currently in the generated stub files, the RPC client is free to connect from 开发者_如何学Go(or listen on) any port. because in the generated file, I see the following
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
I am a newbie to RPC and related things but trying to modify it anyway .... Since I know that the server listens on a particular port, I deduced that the above line is what is causing the client to connect from arbitrary port. Now I kind of know how to fix it ..I would have to try to open a bunch of sockets whose port will be in the given range of ports until I am successful and pass it as the first argument to svctcp_create... However this would have to be in the rpcgen generated files which does not make me very comfortable. I would like to modify the ".x" file so as to do it once for all. can anybody help me with this? Thanks, Sunil
Why do you need to restrict the local ports to a range? There is no support for this at any layer of the TCP networking APIs. Client port ranges are sometimes specified as firewall rules by netadmins who are unaware of the implementation infeasibility, and who think they are adding security, about which they are also mistaken. What's the reason in your case?
精彩评论