In case of JDBC/ODBC, it talks to hive server2 (or hive server1 in older versions) using thrift binary api (thrift protocol over tcp). There is an option to use thrift over http , and its support has been greatly improved in upcoming hive 0.13 release. I believe the http mode is supported since hive 0.12.
In case of hive commandline, there is no rpc to the hive server2. It runs the hive parser/optimizer/scheduler etc within the same have commandline jvm.
Hope this answers your question.