sockopt.go 419 B

123456789101112131415161718192021222324252627282930
  1. package internet
  2. func isTCPSocket(network string) bool {
  3. switch network {
  4. case "tcp", "tcp4", "tcp6":
  5. return true
  6. default:
  7. return false
  8. }
  9. }
  10. func isUDPSocket(network string) bool {
  11. switch network {
  12. case "udp", "udp4", "udp6":
  13. return true
  14. default:
  15. return false
  16. }
  17. }
  18. func (v *SocketConfig) ParseTFOValue() int {
  19. if v.Tfo == 0 {
  20. return -1
  21. }
  22. tfo := int(v.Tfo)
  23. if tfo < 0 {
  24. tfo = 0
  25. }
  26. return tfo
  27. }