Created
January 26, 2018 18:12
-
-
Save mbonell/1e4fe092b774b4ca20fe2074e104f567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net" | |
"net/http" | |
"net/rpc" | |
"github.com/techwo/rpc-server/service" | |
) | |
func main() { | |
s := new(service.Calculator) | |
err := rpc.Register(s) | |
if err != nil { | |
log.Fatal("Service registration error:", err) | |
} | |
rpc.HandleHTTP() | |
l, err := net.Listen("tcp", "localhost:8767") | |
if err != nil { | |
log.Fatal("Listen error:", err) | |
} | |
log.Println("Server started!") | |
log.Println(l.Addr()) | |
err = http.Serve(l, nil) | |
if err != nil { | |
log.Fatal("Server error:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment