The Go net/rpc library documentation enables exposing an object across a network, either via raw network connections or via HTTP.
HTTP Example
arith := new(Arith)
rpc.Register(arith)
rpc.HandleHTTP()
l, e := net.Listen("tcp", ":1234")
if e != nil {
log.Fatal("listen error:", e)
}
go http.Serve(l, nil)
Raw TCP Network Connection
arith := new(Arith)
rpc.Register(arith)
l, e := net.Listen("tcp", ":1234")
if e != nil {
log.Fatal("listen error:", e)
}
go func() {
for {
conn, err := l.Accept()
go rpc.ServeConn(conn)
}
}
To call the first type of server, one would use rpc.DialHTTP("tcp", "127.0.0.1:1234") and for the second type rpc.Dial("tcp", "127.0.0.1:1234") would be used.
My question is how are these two really different? What pros/cons are there to running an HTTP server vs. a "raw network connection" server? Can one perform RPCs via curl or the browser in some way with HTTP? Is the HTTP version useful for cross-language RPC invocation?