在做tcp客户端连接服务器时,有时会报socket.error: [Errno 10048],此问题是由于windows环境下缺省的tcp的MaxUserPort为5000,一旦端口资源耗尽就会产生10048错误,解决办法是到注册表中建立一个MaxUserPort键以修改此参数的缺省值。
MaxUserPort
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
|
Data type |
Range |
Default value |
|---|---|---|
|
REG_DWORD |
5,000–65,534 ( port number ) |
5000 |
Description
Determines the highest port number TCP can assign when an application requests an available user port from the system. Typically, ephemeral ports (those used briefly) are allocated to port numbers 1024 through 5000.
本文探讨了在Windows环境下进行TCP客户端编程时遇到的端口资源耗尽问题,详细解释了错误代码10048的含义,并提供了解决方案:通过修改注册表中的MaxUserPort值来增加可用的端口范围,从而避免因端口不足导致的连接失败。
2万+

被折叠的 条评论
为什么被折叠?



