Python Socket Communication разрывается при удалении оператора печатиPython

Программы на Python
Anonymous
 Python Socket Communication разрывается при удалении оператора печати

Сообщение Anonymous »

Я отправляю многострочную строку Python с сокетом: < /p>

Код: Выделить всё

 elif command=="help":
help_options='''
download 
 -> Download a File from Target Machine
upload    -> Upload a File to Targe
get        -> Download a File to Target Machine from Internet
start  -> Start Program on Target Machine
screenshot      -> Take screenshot of the Target Screen
check           -> Check for Administrator Privileges
'''
lines=help_options.splitlines()
for line in lines:
send_payload(line.encode("utf-8"))
send_payload("END".encode("utf-8"))
< /code>
от клиента это то, как я получаю: < /p>
 elif command=="help":
complete_message=""
while True:
line=receive_payload()
# ---- FIRST TRY FAILED
# if not line:
#     time.sleep(0.01)
#     continue

# --- SECOND  TRY FAILED
# if not line:
#     continue

# --- THIRD TRY FAILED ---
# time.sleep(0.01)

# ------- IT WORKS ONLY WITH THIS PRINT STATEMENT
# print(f"line {line}")
if line=="END":
break
if isinstance(line,bytes):
complete_message += line.decode('utf-8') + "\n"
else:
complete_message+=line+"\n"
print(complete_message)
< /code>
Я успешно получил текст по ошибке, когда добавил эту строку отладки < /p>
   print(f"line {line}")
Кто -нибудь знает, почему цикл работает только при печати полученных данных? Что -то происходит с буфером сокета или способом обработки данных в кусках? >

Код: Выделить всё

receive_payload
и send_payload Функции успешно работают. При необходимости я могу опубликовать


Подробнее здесь: https://stackoverflow.com/questions/793 ... -statement

Вернуться в «Python»