Make this into a function by itself and adjust its arguments so that
when we support multiple sockets (for multiple addresses so that we
can have multiple AFs) we can just call it for each one.
No functional change.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>