Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/rpc : server cannot decode request ... The spcified network name in no longer available. #5766

Closed
gopherbot opened this issue Jun 24, 2013 · 3 comments

Comments

@gopherbot
Copy link

by yodamgod:

What steps will reproduce the problem?

The code is here.
http://jan.newmarch.name/go/rpc/chapter-rpc.html

ArithServer and ArithClient


/**
* ArithServer
 */

package main

import (
    "fmt"
    "net/rpc"
    "errors"
    "net/http"
)

type Args struct {
    A, B int
}

type Quotient struct {
    Quo, Rem int
}

type Arith int

func (t *Arith) Multiply(args *Args, reply *int) error {
    *reply = args.A * args.B
    return nil
}

func (t *Arith) Divide(args *Args, quo *Quotient) error {
    if args.B == 0 {
        return errors.New("divide by zero")
    }
    quo.Quo = args.A / args.B
    quo.Rem = args.A % args.B
    return nil
}

func main() {

    arith := new(Arith)
    rpc.Register(arith)
    rpc.HandleHTTP()

    err := http.ListenAndServe(":1234", nil)
    if err != nil {
        fmt.Println(err.Error())
    }
}



/**
* ArithClient
 */

package main

import (
    "net/rpc"
    "fmt"
    "log"
    "os"
)

type Args struct {
    A, B int
}

type Quotient struct {
    Quo, Rem int
}

func main() {
    if len(os.Args) != 2 {
        fmt.Println("Usage: ", os.Args[0], "server")
        os.Exit(1)
    }
    serverAddress := os.Args[1]

    client, err := rpc.DialHTTP("tcp", serverAddress+":1234")
    if err != nil {
        log.Fatal("dialing:", err)
    }
    // Synchronous call
    args := Args{17, 8}
    var reply int
    err = client.Call("Arith.Multiply", args, &reply)
    if err != nil {
        log.Fatal("arith error:", err)
    }
    fmt.Printf("Arith: %d*%d=%d\n", args.A, args.B, reply)

    var quot Quotient
    err = client.Call("Arith.Divide", args, &quot)
    if err != nil {
        log.Fatal("arith error:", err)
    }
    fmt.Printf("Arith: %d/%d=%d remainder %d\n", args.A, args.B, quot.Quo, quot.Rem)

}


What is the expected output?
just no error message

What do you see instead?

2013/06/24 21:49:56 rpc: rpc: server cannot decode request: WSARecb tcp 127.0.0.1:1234:
The specified network name is no longer avaliable.


Which compiler are you using (5g, 6g, 8g, gccgo)?
amd64 (a.k.a. x86-64); 6g,6l,6c,6a


Which operating system are you using?
Windows 8 64bit Pro K


Which version are you using?  (run 'go version')
go version go1.1.1 windows/amd64

Please provide any additional information below.

The same issue was written 1 year ago, but the problem is not fixed, yet.
https://code.google.com/p/go/issues/detail?can=2&;start=0&num=100&q=&colspec=ID%20Status%20Stars%20Priority%20Owner%20Reporter%20Summary&groupby=&sort=&id=3746

I attached the program so that you can test this issue.

Attachments:

  1. Screenshot - 2013-06-24 , 오후 9_29_37.png (17897 bytes)
  2. Screenshot - 2013-06-24 , 오후 9_29_47.png (9563 bytes)
  3. RPCArith.zip (2731652 bytes)
@chai2010
Copy link
Contributor

Comment 1:

The test program seems has a issue: the rpc client need call client.Close() when the
program exit.

@gopherbot
Copy link
Author

Comment 2 by yodamgod:

oops. I see. Thank you. :p

@davecheney
Copy link
Contributor

Comment 3:

Thanks @chaishushan

Status changed to Retracted.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants