Re: [Tutor] error_connection_refused

2012-06-06 Thread BILAL Mustapha

Hello,

 Thank you for your reply.

 Please read underlines.

Le 05/06/2012 23:12, Alan Gauld a écrit :

On 05/06/12 12:53, BILAL Mustapha wrote:

Hello,


Hi, Its best not to hijack somebody else's thread coz it messes up all 
the threaded mail/news readers out there. (At least you changed the 
subject though!). Please start with a fresh mail for a new topic.




Oops, sorry I didn't pay attention to it..

I am trying to lunch a small python program but I am always getting this
error:


How are you launching it? From a batch file or shell script?
From another Python program? From the Python prompt?


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!!


It sounds like you might be using  a Python  prompt and not 
reloading the module after making changes. importing a second time 
won't work as Python knows you already have it and ignores it. You 
must use reload() for changes to take effect.


If thats not it then we need more details about what you are doing.

I actually found the solution which was somehow trivial, I was not 
listening to an open port so I changed the port and it worked fine.


Thank you again

Regards

HTH,



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] error_connection_refused

2012-06-05 Thread BILAL Mustapha

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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] error_connection_refused

2012-06-05 Thread Alan Gauld

On 05/06/12 12:53, BILAL Mustapha wrote:

Hello,


Hi, Its best not to hijack somebody else's thread coz it messes up all 
the threaded mail/news readers out there. (At least you changed the 
subject though!). Please start with a fresh mail for a new topic.




I am trying to lunch a small python program but I am always getting this
error:


How are you launching it? From a batch file or shell script?
From another Python program? From the Python prompt?


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!!


It sounds like you might be using  a Python  prompt and not reloading 
the module after making changes. importing a second time won't work as 
Python knows you already have it and ignores it. You must use reload() 
for changes to take effect.


If thats not it then we need more details about what you are doing.

HTH,

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] error_connection_refused

2012-06-05 Thread Steven D'Aprano

BILAL Mustapha wrote:


Here is the code:


Unfortunately not. What you have posted contains at least two SyntaxErrors 
that prevents it from running:



def send_data():
*print(test sending data)*
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
*s.connect((IP, PORT))*



Two of those four lines are invalid: the indentation is wrong, and there are 
leading and trailing asterisks * on the lines. Possibly your email program has 
helpfully added them because you marked the lines as bold for some reason.


There may be other errors I haven't spotted.

When sending code, please ensure that you send actual RUNNING code that does 
what you say it does. If you help us to run your code, we can help you fix the 
bug.


Copy and paste from the code you actually run, or attach the file to your 
email as an attachment. Double-check that your email program sends plain text, 
including correct indentation, and not HTML/Rich Text. Double-check the 
indentation is correct.


If you must add comments or annotations to the code, use Python comment syntax

# like this

and not asterisks * or formatting, or animated gifs of dancing bears, or any 
other rubbish that gets in the way of running the code.


This may also help:

http://sscce.org/



Thank you,



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor