Python - Problemas de socket (error: [Errno 111] Connection refused)

 
Vista:
sin imagen de perfil

Problemas de socket (error: [Errno 111] Connection refused)

Publicado por Ladislao (1 intervención) el 11/09/2015 19:48:15
Hola .

Tengo el siguiente codigo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#import httplib2
import socket
from threading import Thread
import make_html
import make_html2
import os.path
#import gtk
#import grafico2
 
# creamos un objeto grafico2
 
#hello = grafico2.HelloWorld()
 
 
def Call_Rachael(torachael, tema, original_sentences, urlpath, Extractors):
	t = Thread(target=socket_, args=(torachael, tema, original_sentences, urlpath, Extractors,))
	t.start()
	return 0
 
def socket_(torachael, tema, original_sentences, urlpath, Extractors):
	HOST = 'localhost'
	PORT = 5556
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	try:
		s.connect((HOST, PORT))
		s.send(torachael)
		data = s.recv(1024)
		if data == "":
			data = s.recv(1024)
		summary = ''
		if os.path.isfile(tema+'~resumen.txt'):
			summary = os.path.abspath(tema+'~resumen.txt')
			make_html.Making_html(tema, urlpath, original_sentences, summary, Extractors)
			print 'comienzo del segundo resmen'
			make_html2.Making_html(tema, urlpath, original_sentences, summary, Extractors)
			print '--------------------------------------DONE-------------------------------------'
			#hello.main()
 
		else:
			print "Error summary not found!..."
			return 1
		print "Socket Receive back "+data
		return 0
	finally:
		print "Cerramos el socket"
		s.close()

lo cual me genera el siguiente error:

1
2
3
4
5
6
7
8
9
10
11
12
13
Exception in thread Thread-1:Traceback (most recent call last):
  File "/home/juancz/NetBeansProjects/Kukulkan-Ladislao/build/lib/jython-standalone-2.7-b1.jar/Lib/threading.py", line 184, in _Thread__bootstrap
    self.run()
  File "/home/juancz/NetBeansProjects/Kukulkan-Ladislao/build/lib/jython-standalone-2.7-b1.jar/Lib/threading.py", line 175, in run
    self._target(*self._args, **self._kwargs)
  File "lib/python/socket_.py", line 28, in socket_
    s.connect((HOST, PORT))
  File "<string>", line 1, in connect
  File "/home/juancz/NetBeansProjects/Kukulkan-Ladislao/build/lib/jython-standalone-2.7-b1.jar/Lib/socket.py", line 180, in set_last_error
    return method(obj, *args, **kwargs)
  File "/home/juancz/NetBeansProjects/Kukulkan-Ladislao/build/lib/jython-standalone-2.7-b1.jar/Lib/socket.py", line 171, in map_exception
    raise _map_exception(jlx)
error: [Errno 111] Connection refused

tengo corriendo en otra maquina el mismo codigo, pero me funciona, bien, ya verifique todo estuviera correcto, la version, etc. Pueden ayudar por favor. de ante mano agradezco cualquier comentario.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder