def nl_socket_alloc(cb=None):
<EOL>cb = cb or nl_cb_alloc(default_cb)<EOL>if not cb:<EOL><INDENT>return None<EOL><DEDENT>sk = nl_sock()<EOL>sk.s_cb = cb<EOL>sk.s_local.nl_family = getattr(socket, '<STR_LIT>', -<NUM_LIT:1>)<EOL>sk.s_peer.nl_family = getattr(socket, '<STR_LIT>', -<NUM_LIT:1>)<EOL>sk.s_seq_expect = sk.s_seq_next = int(time.time())<EOL>sk.s_flags = NL_OWN_PORT  <EOL>nl_socket_get_local_port(sk)  <EOL>return sk<EOL>
Allocate new Netlink socket. Does not yet actually open a socket.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L206

    Also has code for generating local port once.
    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L123

    Keyword arguments:
    cb -- custom callback handler.

    Returns:
    Newly allocated Netlink socket (nl_sock class instance) or None.