[Tutor] error_connection_refused
BILAL Mustapha
Mustapha.Bilal at imag.fr
Tue Jun 5 13:53:09 CEST 2012
Hello,
I am trying to lunch a small python program but I am always getting
this error:
s.connect((IP, PORT))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
What's weird that it doesn't even print the line "test sending data" so
how it could get to s.connect() without passing through this line!!
Here is the code:
#!/usr/bin/python
import socket
import thread
import time
from threading import Thread
import threading
import sys
IP = "130.190.31.167"
PADDING = "a" * 1000
DATA = PADDING + "this is sentence number = "
PORT = 8000
killed = False
count=0
def main():
print("the network manager process is created")
send_data()
def send_data():
*print("test sending data")*
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
*s.connect((IP, PORT))*
while killed==False:
count= count+1
sent = s.send(DATA+ str(count) + "\n")
if sent == 0:
print 'The connection is died'
killed=True
s.close()
if __name__ == "__main__":
main()
Many thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120605/cc76d371/attachment.html>
More information about the Tutor
mailing list