Python客户端不会重新连接到

2024-03-28 16:31:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我对我的英语很抱歉,但是我的软件有些问题,我需要一些帮助。但首先,一些代码!在

客户端:

if connessione.connect(host, port) == True:
    connect = True
    print 'connection granted'
else:
    connect = False
    print 'connection refused'

while 1:
   do_some_stuff_with_socket

   if connect == False:
       if connessione.connect(host, port) == True:
           connect = True

服务器端:(在互联网上找到)

^{pr2}$

如果重新启动/断开服务器,则客户端不会重新连接。我使用了.terminate().close()方法来关闭套接字。在


Tags: 代码falsetruehost客户端if软件port