码迷,mamicode.com
首页 > 编程语言 > 详细

python小程序之并发连接

时间:2017-01-09 23:03:14      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:rip   code   for   start   set   脚本   span   class   pre   

 1 import threading
 2 import  socket
 3 import time
 4 def conn():
 5     cli = socket.socket()
 6     cli.connect(("58.68.232.139",80))
 7     while True:
 8         data = input(">>>").strip()
 9         if len(data)  == 0:continue
10         cli.send(data.encode())
11         reciv = cli.recv(1024)
12         print(reciv)
13 for i in range(2000):
14     t =threading.Thread(target=conn)
15     t.setDaemon(True)
16     t.start()
17 time.sleep(15)
18 print("--main--")

注:此脚本慎用 !!!!!!!

python小程序之并发连接

标签:rip   code   for   start   set   脚本   span   class   pre   

原文地址:http://www.cnblogs.com/liruixin/p/6266665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!