Source file
src/net/sockaddr_posix.go
1
2
3
4
5
6
7 package net
8
9 import (
10 "syscall"
11 )
12
13
14
15 type sockaddr interface {
16 Addr
17
18
19
20 family() int
21
22
23
24 isWildcard() bool
25
26
27
28
29
30 sockaddr(family int) (syscall.Sockaddr, error)
31
32
33 toLocal(net string) sockaddr
34 }
35
36 func (fd *netFD) addrFunc() func(syscall.Sockaddr) Addr {
37 switch fd.family {
38 case syscall.AF_INET, syscall.AF_INET6:
39 switch fd.sotype {
40 case syscall.SOCK_STREAM:
41 return sockaddrToTCP
42 case syscall.SOCK_DGRAM:
43 return sockaddrToUDP
44 case syscall.SOCK_RAW:
45 return sockaddrToIP
46 }
47 case syscall.AF_UNIX:
48 switch fd.sotype {
49 case syscall.SOCK_STREAM:
50 return sockaddrToUnix
51 case syscall.SOCK_DGRAM:
52 return sockaddrToUnixgram
53 case syscall.SOCK_SEQPACKET:
54 return sockaddrToUnixpacket
55 }
56 }
57 return func(syscall.Sockaddr) Addr { return nil }
58 }
59
View as plain text