August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, you are going to see the Go code of the RPC client, which will be saved as RPCclient.go and presented in four parts.
The first part of RPCclient.go is as follows:
package main
import (
"fmt"
"net/rpc"
"os"
"sharedRPC"
)
The second segment of RPCclient.go contains the following Go code:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide a host:port string!")
return
}
CONNECT := arguments[1]
c, err := rpc.Dial("tcp", CONNECT)
if err != nil {
fmt.Println(err)
return
}
Observe the use of the rpc.Dial() function for connecting to the RPC server instead of the net.Dial() function, even though the RCP server uses TCP.
The third segment of RPCclient.go is as follows:
args := ...
Read now
Unlock full access