C# TcpListener is reachable only from local

I started TcpListener on C# with this code:

serverSocket = new TcpListener (IPAddress.Any, 8080); serverSocket.Start (); TcpClient client = serverSocket.AcceptTcpClient ();

simple TcpListener which is running on the new C# thread.
Problem is that I am not able to connect it from other networks, not even from LAN.
If I try to connect it from the PC where the service is running it works but not from other networks.

I’ve started java server on the same port to see if there is some problem with IP addresses and stuff and it works nothing wrong with networking …

Is there a chance that Unity blocks other networks?

if you are through the internet you need to make sure you are on a static ip and your router has port forwarding setup to run a server on your device at home.

you need your router to have the port in your code forwarded to your machines local address!!!
and then finally you need your device to request the same local address everytime.

you would need a bit more code than what you are posting to hear anything. I know it seems weird but as microsofts docs say, Generally you would use a while(true) loop after what you have to keep your code running so that it stays open and keeps listening.

then it would be reccommended that you create a new thread when you hear something so your sever can respond to multiple incomming messages.

then finally you need to create a buffer or byte array to grab the incomming message.

if you know that your messages will be limited to a certain size then you can just pick an appropriate size for your buffer.

    TcpListener server = new TcpListener (IPAddress.Any, 8080); 
         server.Start (); 
         while (true)
                         {
                             // Perform a blocking call to accept requests.
                             // You could also user server.AcceptSocket() here.
                             Socket client = server.AcceptSocket();
         
                             var childSocketThread = new Thread(() =>{
          Byte[] data = new Byte[1024];
         
                             int datasize = client.Receive(data);
                           
         //the data should be holding the message in byte array format;
         // the datasize variable tells how many bytes you received up to 1024
    byte[] SomeByteArrayAnswer=something????
    client.Send(SomeByteArrayAnswer);
    client.Close();
          });
                         childSocketThread.Start();}