Re: Newbie: Keep TCP socket open
Alan Wright wrote:
> while (num1<=10) :
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(("10.1.1.69", 50008)) # SMTP
> print s.recv(1024) + '\n',
I think the following is happening:
Reusing the 's' object for every new socket will make Python to garbage
collect the previous ones. Garbage collecting a socket will likely close() it.
Also after creating all sockets your program exits. I guess either Python or the
operating system itself will go close all the sockets.
Try putting every new socket you make into a big list instead, so that Python can't
garbage collect it. And put your program to sleep at the end.
|All times are GMT. The time now is 11:05 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.