linux - Golang UDP Server only recieving locally sent packets -


i've written udp server in go(listens on port 666), , seems receiving packets sent locally. confirm traffic, have been using:

sudo tcpdump -n udp dst port 666 

my(abbreviated) server code:

import "net"  func startserver() {     // bind port.     serveraddr, err := net.resolveudpaddr("udp", "localhost:666")     if err != nil {         fmt.println("error binding port!")     }      serverconn, _ := net.listenudp("udp", serveraddr)     defer serverconn.close()      buf := make([]byte, 1024)     {         // recieve udp packet , unmarshal protobuf.         n, _, _ := serverconn.readfromudp(buf)         fmt.println("packet received!")         // stuff buf.     } } 

if, machine server running on, use:

echo -n “foo” | nc -4u -w1 127.0.0.1 666 

then server receives packet, , prints message(and tcpdump shows no output).

however, if run following computer on network:

echo -n “foo” | nc -4u -w1 192.168.1.134 666 

then, while tcpdump reports packet being received (15:05:43.634604 ip 192.168.1.113.59832 > 192.168.1.134.666: udp, length 9 confirming got ip address right), go server not respond.

is there special need make go respond non-local requests?

just listen on address, you're listening on localhost only.

serveraddr, err := net.resolveudpaddr("udp", ":666") 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -