Golang net.ResolveUDPAddr(), ListenMulticastUDP(), ListenUDP and DialUDP() functions example
package net
Golang net.ResolveUDPAddr() and DialUDP() functions usage example
rAddr,err := net.ResolveUDPAddr("udp","127.0.0.1:8081")
if err != nil {
fmt.Println(err)
}
lAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
if err != nil {
fmt.Println(err)
}
//conn, err := net.DialUDP("udp", LocalAddr, RemoteAddr)
UDPConn, err := net.DialUDP("udp", lAddr, rAddr)
if err != nil {
fmt.Println(err)
}
// other functions example
LMConn, err := net.ListenMulticastUDP("udp", nil, rAddr)
Lconn, err := net.ListenUDP("udp", laddr)
References :
http://golang.org/pkg/net/#DialUDP
http://golang.org/pkg/net/#ListenMulticastUDP
Advertisement
Something interesting
Tutorials
+4.7k JavaScript: Add marker function on Google Map
+9.9k Golang : Turn string or text file into slice example
+10.5k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+9.7k Golang : Populate slice with sequential integers example
+11.3k Golang : Characters limiter example
+10.1k Golang : Identifying Golang HTTP client request
+11k Golang : Generate random elements without repetition or duplicate
+5.4k Unix/Linux : How to archive and compress entire directory ?
+13.8k Golang : Convert spaces to tabs and back to spaces example
+10k Golang : Convert octal value to string to deal with leading zero problem
+41.2k Golang : How to count duplicate items in slice/array?
+10.4k Golang : Meaning of omitempty in struct's field tag