def tcplink(sock, addr):
print('Accept new connection from %s:%s...' % addr)
sock.send(b'Welcome!')
while True:
data = sock.recv(1024)
time.sleep(1)
if not data or data.decode('utf-8') == 'exit':
break
# execute what you want
sock.close()
print('Connection from %s:%s closed.' % addr)
直接在服务器上运行python脚本,监听某个不使用的端口。当端口接收到信号时,运行要执行的脚本。
如何创建套接字服务:
使服务器中的服务保持活动状态。在
相关问题 更多 >
编程相关推荐