📜  python socket获取客户端ip - Python代码示例

📅  最后修改于: 2022-03-11 14:46:12.237000             🧑  作者: Mango

代码示例3
# If you are connected to the client socket you can get its address
client_socket.getpeername()
# Expected return value is a Tuple (ip, port)

# You can also get your own socket address
client_socket.getsockname()
# Expected return value is a Tuple (ip, port)