I am getting an unexpected EOF error after the execution of Call function in client code.I have a tcp server listening on port 8081 and have defined custom format for RPC request and response type.
Client Code
c, err := rpc.Dial("tcp", "127.0.0.1:8081")
if err != nil {
fmt.Fprintf(w, "Tcp Connection Error")
return
}
defer c.Close()
response := new(Result)
err = c.Call("Profile.Manage", msg, response)
if err != nil {
fmt.Println(err)
}
Server Code
handleobj := login_change.NewProfile()
rpc.Register(handleobj)
PORT := "127.0.0.1:8081"
l, err := net.Listen("tcp", PORT)
if err != nil {
fmt.Println(err)
return
}
defer l.Close()
rpc.Accept(l)
Common Package
type Profile struct{}
func (h *Profile) Manage(b Msgobject, res *Result) (err error) {
res.Message = "Control reached"
return nil
}
func NewProfile() *Profile {
return &Profile{}
}
It's resolved now,I was actually trying to perform operations on a variable which was initialized by a different process thus resulting in this issue.