An RPC is like your boss calling you and telling you to complete a task for them because they aren’t there or can not do it themselves. Likewise, RPCs are a mechanism for safely requesting a remote machine to execute a piece of code that both machines know about.
They are primarily used in higher performance client/server networking code where parsing API packets would be too expensive or slow (games being a primary example).
As for why; well, security first and foremost, and performance second. You can’t just send a chunk of code to execute in any safe manner for many reasons. Doing so is called arbitrary code execution, and it is pretty much the worst-case scenario for security. So developers implement RPCs to allow a server to have a certain level of “safe” control over a client machine without actually running any code the server wants.
Latest Answers