How to use Twisted on Mac OSX?

Asked

Viewed 49 times

1

I’m following a tutorial to use Twisted to establish connection to an app. However, when testing the connection to localhost for testing, it seems that it is not responding.

I am using the following script in 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 the following error returns to me:

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 I can make Twisted work on Mac OSX?

1 answer

1


My first suggestion is whenever you choose another door, like 8000. In OSX usually only processes executed with root can open doors below 1024. This can be changed but I do not recommend.

If you really need to use the door 80, OSX comes with a utility called ipfw which allows redirecting the port 80 to the 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 door 8000 and still access it at the door 80.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.