-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
是否可以查看客户端的所开的端口 #149
Comments
软件没做这个,一般不会用到这个功能吧,在服务端那边可以看到没必要在客户端这边看 |
不过一定要看的话是可以的,可以自己加上, demo 如下: import socket
# 创建一个 socket 对象
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 连接到服务器
server_address = ('localhost', 12345)
client_socket.connect(server_address)
# 获取客户端的 IP 地址和端口号
client_ip, client_port = client_socket.getsockname()
print(f"Client IP: {client_ip}, Client Port: {client_port}")
# 关闭连接
client_socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
一般连接后,服务端可以看到连接的客户端的 IP|Port 那其实客户端也能知道自己的IP|Port. 这个可以在哪里看到呢?
The text was updated successfully, but these errors were encountered: