The following server code has a problem. The write by server to
connection always fails.
I have not been able to find the solution.
--
package main
import (
"fmt";
"net";
"os";
"strings";
)
func main() {
var buf [1000]byte;
sout := "The answer";
bout := strings.Bytes(sout);
laddr, err := net.ResolveUDPAddr("
127.0.0.1:6854");
if err != nil { fmt.Println("Resolv.."); os.Exit(1); }
c, erl := net.ListenUDP("udp", laddr);
if erl != nil { fmt.Println("Listen.."); os.Exit(1); }
n, erd := c.Read(buf[0:128]);
if erd != nil { fmt.Println("Read.."); os.Exit(1); }
fmt.Println("Read: ", n);
fmt.Println("Writing: ", len(bout));
_, erw := c.Write(bout); //fails
if erw != nil { fmt.Println("Write.."); os.Exit(1); }
fmt.Print("Main stops\n");
}
--
-ish