TcpClient not connecting when the network cable is not plugged

Hi everybody,

I have a little problem with TcpClient in my application : it doesn’t connect to my server on localhost if the network cable is not plugged.

Here is the complete thing. I have a C# TcpServer on my computer, a C# TcpClient and a TcpClient in my Unity app. The TcpClient is in a dll imported in my Unity project. Everything was going fine, the 2 clients could connect to the server without problem on localhost.

Then I tried to unplugged the network cable from my computer to test offline. The C# TcpClient is still connecting but the TcpClient in Unity doesn’t want to.

The cases I have tried :

  • Cable plugged => OK
  • Cable unplugged => NOK
  • Cable plugged at start then unplugged after the connection => still OK (no deconnection)
  • Cable unplugged at start then plugged during the run => The client connects to the server after the cable is plugged

Can you help me find what am I doing wrong ? What I have forget to do to make it work ?

Thanks in advance

I fixed it by replacing “localhost” by “”