Skip to content

Commit ebf6044

Browse files
committed
新增本地端口绑定
1 parent 68b6fa8 commit ebf6044

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

socket/tcp/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ class TcpClient:
1111
PORT = 1122
1212
BUFSIZ = 1024
1313
ADDR = (HOST, PORT)
14+
LOCAL_ADDR = ('', 2225)
1415

1516
def __init__(self):
1617
self.client = socket(AF_INET, SOCK_STREAM)
18+
# self.client.bind(self.LOCAL_ADDR) # 绑定本地端口,可选
1719
self.client.connect(self.ADDR)
1820

1921
while True:

0 commit comments

Comments
 (0)