add chapter 15.9 (#686)

This commit is contained in:
marjune
2019-07-19 11:55:26 +08:00
committed by ᴊ. ᴄʜᴇɴ
parent c35513e355
commit e4c10d1d56
8 changed files with 284 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
// rpc_server.go
// after client-exits the server shows the message:
// 1:1234: The specified network name is no longer available.
// 2011/08/01 16:19:04 rpc: rpc: server cannot decode request: WSARecv tcp 127.0.0.
package main
import (
"net/http"
"log"
"net"
"net/rpc"
"time"
"./rpc_objects"
)
func main() {
calc := new(rpc_objects.Args)
rpc.Register(calc)
rpc.HandleHTTP()
listener, e := net.Listen("tcp", "localhost:1234")
if e != nil {
log.Fatal("Starting RPC-server -listen error:", e)
}
go http.Serve(listener, nil)
time.Sleep(1000e9)
}
/* Output:
Starting Process E:/Go/GoBoek/code_examples/chapter_14/rpc_server.exe ...
** after 5 s: **
End Process exit status 0
*/