Sto seguendo un tutorial http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server per creare un esempio utilizzando la programmazione socket in ambiente Mac OS X.Reattore twistato Python - indirizzo già in uso
Sto scrivendo utilizzando il post 80 per reactor.listenTCP (80, factory). Quando eseguo il file server.py, ottenendo un errore:
File "server.py", line 10, in <module>
reactor.listenTCP(6, factory)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/posixbase.py", line 436, in listenTCP
p.startListening()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/tcp.py", line 641, in startListening
raise CannotListenError, (self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on any:80: [Errno 48] Address already in use.
Il codice sorgente è la seguente:
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
print "clients are ", self.factory.clients
def connectionLost(self, reason):
self.factory.clients.remove(self)
factory = Factory()
factory.protocol = IphoneChat
factory.clients = []
reactor.listenTCP(80, factory)
print "Iphone Chat server started"
reactor.run()
Se sto utilizzando un altro porto non come 6 ecc, si sta lavorando bene . Volevo solo sapere, come posso usare la porta 80 per la stessa applicazione.
La porta 80 è riservata per il protocollo HTTP. Controlla se non è in corso il processo su questa porta. Forse qualche server HTTP, come l'apache? –