Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
通常情况下,当 tcp 客户端连接到 tcp 服务器时,它有一个随机的接收端口。所以我想知道在 tcp 客户端(windows socket,mfc)中修复这个端口的任何方法。
您可以在调用Connect()之前调用Create()来指定端口:
CSocket yourSocket; yourSocket.Create(sourcePort); yourSocket.Connect(targetHost, targetPort);