Hi guys,
I wrapped some code to do listen UDP port and set priority, like this
func ListenUDP(t string, laddr *net.UDPAddr, priority int) (*net.UDPConn,
error) {
conn, err := net.ListenUDP(t, laddr)
if err != nil {
return nil, err
}
if priority < 0 {
return conn, nil
}
file, err := conn.File()
if err != nil {
conn.Close()
return nil, fmt.Errorf("error in getting file for the connection")
}
defer file.Close()
err = syscall.SetsockoptInt(int(file.Fd()), syscall.SOL_SOCKET,
syscall.SO_PRIORITY, priority)
if err != nil {
return nil, fmt.Errorf("error in setting priority option on socket:
%s", err)
}
return conn, nil
}
And, read data from that port with timeout
conn.SetReadDeadline(time.Now().Add(time.Second * 5))
n, addr, err = conn.ReadFromUDP(buf)
But, i found the deadline not work...
Any good suggestions?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.