Copied (almost verbatim) from SPARK-10997 Netty-based RPC env should support a "client-only" mode and the commit:
"Client mode" means the RPC env will not listen for incoming connections.
This allows certain processes in the Spark stack (such as Executors or tha YARN client-mode AM) to act as pure clients when using the netty-based RPC backend, reducing the number of sockets Spark apps need to use and also the number of open ports.
The AM connects to the driver in "client mode", and that connection is used for all driver — AM communication, and so the AM is properly notified when the connection goes down.
In "general", non-YARN case,
clientMode flag is therefore enabled for executors and disabled for the driver.