To use: .setsockopt(SOL_SOCKET, 20, lambda sock: print(sock)). There's a single underlying callback slot. For normal sockets, it serves as data received callback, for listening sockets - connection arrived callback.