Last active
April 21, 2017 02:31
-
-
Save SLonger/c8b25a9e72ccc0fa3969d6b8cf3d143d to your computer and use it in GitHub Desktop.
golang test udp socket buffer after set it value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
// "os" | |
"syscall" | |
) | |
const ( | |
WriteBuffer = 8192 | |
) | |
func main() { | |
addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:8089") | |
conn, err := net.DialUDP("udp", nil, addr) | |
if err != nil { | |
fmt.Printf("Some error %v", err) | |
return | |
} | |
defer conn.Close() | |
err = conn.SetWriteBuffer(WriteBuffer) | |
if err != nil { | |
fmt.Println("set error", err) | |
} | |
fd, _ := conn.File() | |
value, _ := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) | |
fmt.Println(value) | |
fd.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment