December 2017
Intermediate to advanced
316 pages
6h 58m
English
Now, the client also uses the same net/rpc package but uses different methods to dial to the server and get the remote function executed. The only way to get data back is to pass the reply pointer object along with the request, as shown in the following code snippet:
package mainimport ( "log" "net/rpc")type Args struct {}func main() { var reply int64 args := Args{} client, err := rpc.DialHTTP("tcp", "localhost"+":1234") if err != nil { log.Fatal("dialing:", err) } err = client.Call("TimeServer.GiveServerTime", args, &reply) if err != nil { log.Fatal("arith error:", err) } log.Printf("%d", reply)}The client is performing the following things here:
Read now
Unlock full access