Я пытаюсь написать простой клиент / сервер (где клиент и сервер не являются одним и тем же компьютером) и не могу понять, как дать витому IP-адрес.
from twisted.internet import protocol, reactor, endpoints
from twisted.protocols import basic
class FingerProtocol(basic.LineReceiver):
def lineReceived(self, user):
self.transport.write(self.factory.getUser(user) + b"\r\n")
self.transport.loseConnection()
class FingerFactory(protocol.ServerFactory):
protocol = FingerProtocol
def __init__(self, users):
self.users = users
def getUser(self, user):
return self.users.get(user, b"No such user")
fingerEndpoint = endpoints.serverFromString(reactor, ("192.168.1.7", "tcp:1079"))
fingerEndpoint.listen((FingerFactory({ b'moshez' : b'Happy and well'})))
reactor.run()
ошибка:
Traceback (most recent call last):
File "sensors/twistedTest.003.py", line 20, in <module>
fingerEndpoint = endpoints.serverFromString(reactor, ("192.168.1.7", "tcp:1079"))
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/endpoints.py", line 1724, in serverFromString
nameOrPlugin, args, kw = _parseServer(description, None)
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/endpoints.py", line 1635, in _parseServer
args, kw = _parse(description)
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/endpoints.py", line 1596, in _parse
for (type, value) in _tokenize(description):
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/endpoints.py", line 1570, in _tokenize
current += n
TypeError: can't concat bytes to tuple
Как мне дать витому / реактору IP-адрес?