Move ip_multicast.* to sock_funcs.* and rewrite.

Extracted individual functions for socket-setting.