Search Unity

Odd behavior with Unity 2021.2.4f1 tcpClient and TCP server in .NET 6.0

Discussion in 'Multiplayer' started by RageByte, Dec 30, 2021.

  1. RageByte

    RageByte

    Joined:
    Jul 2, 2017
    Posts:
    34
    I have a server written in C# .NET 6.0 and it's using TCP await stream.ReadAsync etc. in a loop to read client data. I have two clients. One is in .NET 6.0 and the other is in Unity 2021.2.4f1. The .NET client works as expected. The server code waits at the await ReadAsync until there is data. If the client closes, it throws an exception. On the Unity client, it's all haywire. The server code doesn't wait at await which eats up cpu cycles and it keeps returning 0 bytes read (which can indicate the remote client shutdown). It doesn't throw an exception if I shut down the Unity client. Any insight or ideas on what's going on?