Created
December 1, 2023 20:30
-
-
Save zr0n/ea267ba74c1c085cdc74198d157d8de6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
SERVER_HOST = "127.0.0.1" # Endereço do servidor C++ | |
SERVER_PORT = 8080 # Porta do servidor C++ | |
# Criação do socket | |
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# Conexão ao servidor C++ | |
client_socket.connect((SERVER_HOST, SERVER_PORT)) | |
try: | |
while True: | |
# Recebe a resposta do servidor C++ | |
data = client_socket.recv(1024) | |
print(f"Resposta do servidor C++: {data.decode()} \n") | |
except KeyboardInterrupt: | |
print("\nCliente interrompido pelo usuário.") | |
finally: | |
# Fecha o socket | |
client_socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment