September 2017
Intermediate to advanced
466 pages
9h 33m
English
In this section, we will develop an RPC client named RPCclient.go. The Go code of RPCclient.go will be presented in five parts; the first part is the following:
package main import ( "fmt" "net/rpc" "os" "sharedRPC" )
Note the use of the sharedRPC package in the RPC client.
The second part of RPCclient.go is the following:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide a host:port string!")
os.Exit(100)
}
CONNECT := arguments[1]
The third part of the program has the following Go code:
c, err := rpc.Dial("tcp", CONNECT)
if err != nil {
fmt.Println(err)
os.Exit(100)
}
args := sharedRPC.MyInts{17, 18, true, false}
var reply int
As the MyInts structure is defined in sharedRPC.go, you ...
Read now
Unlock full access