У меня ошибка подключения: [winerror 10054], когда я отправляю строку через tcpip в приложение as3 Air.
self.connect.sendall (output.encode ('utf-8'), 1)
вывод выглядит как выход = '0,1,0,0,0,6,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0 «
tcpIpSender - это процесс, который я могу отправить, я просматриваю время, затем разрывается соединение. Я положил несколько снов за посылку, ничего.
def run(self):
while True:
# print("isTCPIPConnected", self.isTCPIPConnected)
while not self.isTCPIPConnected:
try:
self.s.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Bind to TCP port No. 50505 ...
self.s.bind(('', tcpIpPort))
print("try to bind")
# ... and listen for anyone to contact you
# queueing up to five requests if you get a backlog
self.s.listen(1)
# loop der auf TCPIP connected wartet
while True:
# Wait for a connection
self.connect, self.address = self.s.accept()
tcpResponse = (self.connect.recv(4096)).strip()
if self.debug==True:
print("tcpResponse:", tcpResponse)
# vergleich des string, nicht der bytes
if tcpResponse.decode() == "Flash connected":
print("Flash connected")
self.isTCPIPConnected = True
output = 'ahallobx'
self.connect.sendall(output.encode('utf-8'), 1)
break
except Exception as msg:
print (msg)
print ("Exception!!!!")
time.sleep(1)
senddataNew = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
posCnt = 0
for value in self.senddata:
senddataNew[posCnt] = value
posCnt += 1
# nur schicken wenn neuer String
if senddataNew != self.senddataLast:
senddataLast = senddataNew.copy()
posCnt = 0
message = 'a'
for value in self.senddata:
#print("rfidNr " + str(process.stateA[0]) + " ledstate " + str(process.ledState.value) + " on: " + str(process.on) )
#print(self.senddata[posCnt])
self.senddataLast[posCnt] = value
message += str(value) + ","
posCnt += 1
message += "bx"
# print(message)
self.connect.sendall(message.encode('utf-8'), 1)
time.sleep(0.1)