def create_socket(host, family=socket.AF_INET, type=socket.SOCK_STREAM,
                  backlog=2048, blocking=True, inheritable=False):
    if family == socket.AF_UNIX and not host.startswith('unix:'):
        raise ValueError('Your host needs to have the unix:/path form')
    if host.startswith('unix:'):
        family = socket.AF_UNIX

    if host.startswith('fd://'):
        fd = int(host[5:])
        sock = socket.fromfd(fd, family, type)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    else:
        sock = socket.socket(family, type)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        if host.startswith('unix:'):
            filename = host[len('unix:'):]
            try:
                os.remove(filename)
            except __HOLE__:
                pass
            sock.bind(filename)
        else:
            if ':' in host:
                host, port = host.rsplit(':', 1)
                port = int(port)
            else:
                host, port = '0.0.0.0', int(host)
            sock.bind((host, port))
        sock.listen(backlog)

    if blocking:
        sock.setblocking(1)
    else:
        sock.setblocking(0)

    # Required since Python 3.4 to be able to share a socket with a child
    # process.
    if inheritable and hasattr(os, 'set_inheritable'):
        os.set_inheritable(sock.fileno(), True)

    return sock
dataset/ETHPy150Open deliveryhero/lymph/lymph/utils/sockets.py/create_socket