MCPcopy Create free account
hub / github.com/facebook/time / AddrToSockaddr

Function AddrToSockaddr

timestamp/timestamp.go:200–205  ·  view source on GitHub ↗

AddrToSockaddr converts netip.Addr + port into a socket address

(ip netip.Addr, port int)

Source from the content-addressed store, hash-verified

198
199// IPToSockaddr converts IP + port into a socket address
200// Somewhat copy from https://github.com/golang/go/blob/16cd770e0668a410a511680b2ac1412e554bd27b/src/net/ipsock_posix.go#L145
201func IPToSockaddr(ip net.IP, port int) unix.Sockaddr {
202 if ip.To4() != nil {
203 sa := &unix.SockaddrInet4{Port: port}
204 copy(sa.Addr[:], ip.To4())
205 return sa
206 }
207 sa := &unix.SockaddrInet6{Port: port}
208 copy(sa.Addr[:], ip.To16())

Callers 3

runMulticastProbeFunction · 0.92
NewClientFunction · 0.92
TestAddrToSockaddrFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestAddrToSockaddrFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…