Skip to content

Erro ao usar sendcrash com UDP #1

@MateusSeabra

Description

@MateusSeabra

PROCEDIMENTO

python ./initialize_client.py (Usei em 3 terminais diferentes)

Terminal A: send hello-world! [('127.0.0.1',49643)]

Terminal B recebeu a mensagem

Terminal A: sendcrash hello-world! 1 [('127.0.0.1',49657),('127.0.0.1',49643)]

Deu erro no Terminal A e, por algum motivo, o terminal A e B receberam ambos a mensagem. Acho que porque não conseguiu dar shutdown

ERRO

sendcrash hello-world! 1 [('127.0.0.1',49657),('127.0.0.1',49643)]
INFO:app.client:<Client ('0.0.0.0', 49630)> Sending message to ('127.0.0.1', 49657).
Traceback (most recent call last):
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\initialize_client.py", line 66, in
initialize_cli(client)
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\initialize_client.py", line 15, in initialize_cli
running = interpret_cmd(client, cmd)
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\initialize_client.py", line 49, in interpret_cmd
client.r_multicast(msg, group, crash_after=crash_after)
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\app\client.py", line 134, in r_multicast
self.crash()
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\app\client.py", line 67, in crash
self.disconnect()
File "C:\Users\Mateus\Documents\Documentos_Mateus\Documentos_Unity\reliable-multicast\app\client.py", line 55, in disconnect
self._socket.shutdown(0)
OSError: [WinError 10057] Uma solicitação de envio ou recebimento de dados não foi permitida porque o soquete não está conectado e (durante o envio em um soquete de datagrama usando-se uma chamada sendto) não foi fornecido um endereço

POSSÍVEL SOLUÇÃO

def disconnect(self) -> None:
if not self.is_connected():
logging.warn("Attempted to disconnect without a connection.")
return
assert (self._socket is not None) # NOTE: Just so LSP works properly

    try:
        self._socket.shutdown(0)  # Só se for TCP
    except OSError:
        pass  # Ignora erro se for UDP
    self._socket.close()
    del self._socket
    self._socket = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions