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

Client connects but don't see any handling data #285

Open
delp opened this issue Jun 22, 2020 · 0 comments
Open

Client connects but don't see any handling data #285

delp opened this issue Jun 22, 2020 · 0 comments

Comments

@delp
Copy link

delp commented Jun 22, 2020

Can you help me understand why I'm not getting any output after the send?

I have these two programs running in different terminals on the same host.

Listener

func main() {

	if len(os.Args) != 2 {
		panic("ahhh")
	}

	address := os.Args[1]
	port, err := strconv.Atoi(address)
	check(err)
	port16 := uint16(port)

	listener, err := noise.NewNode(noise.WithNodeBindPort(port16))
	check(err)

	defer listener.Close()

	listener.Handle(func(ctx noise.HandlerContext) error {
		if !ctx.IsRequest() {
			return nil
		}

		fmt.Printf("Got a message: '%s'\n", string(ctx.Data()))

		return ctx.Send([]byte("Hi"))
	})

	check(listener.Listen())

	fmt.Println("listening on", listener.Addr())

}

Sender

func main() {

	if len(os.Args) != 2 {
		panic("ahhh")
	}

	address := os.Args[1]
	sender, err := noise.NewNode()
	check(err)

	defer sender.Close()

	check(sender.Listen())

	check(sender.Send(context.TODO(), address, []byte("Hi Bob!")))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant