How to use Twisted in Mac OSX?

1

I'm following a tutorial to use Twisted to connect to an app. But at the time of testing the connection to localhost for testing, it appears that it is not responding.

I am using the following script in the chatserver.py file:

from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor

class IphoneChat(Protocol):
    def connectionMade(self):
        print " um cliente conectado"

factory = Factory()
factory.protoco = IphoneChat
reactor.listenTCP(80, factory)
print "Iphone Chat server started"
reactor.run()

Then I open another console window to test with the following command:

telnet localhost 80

And I get the following error:

  

Trying :: 1 ... telnet: connect to address :: 1: Connection refused   Trying 127.0.0.1 ... telnet: connect to address 127.0.0.1: Connection   refused telnet: Unable to connect to remote host

How do I get Twisted to work on Mac OSX?

    
asked by anonymous 05.12.2014 / 22:00

1 answer

1

My first suggestion is whenever you choose on another port, such as 8000 . On OSX normally only processes running with root can open ports below 1024. This can be changed but I do not recommend it.

If you really need to use the 80 port, OSX comes with a utility called ipfw that allows you to redirect the port 80 to 8000 :

sudo ipfw add 100 fwd 127.0.0.1,8000 tcp from any to me 80

Now you can change your program to the 8000 port and still access it on the 80 port.

    
10.12.2014 / 04:07