Search code examples
c#socketstcplistener

TCP Port listener not working


I need to connect a handheld with a PC. So I'm following this MSDN example which has a Client and a Server program.

Now, the handheld is connected through GPRS. If I run the Client program on the handheld and listen to the port on the PC, I see the data that the handheld send. But if I run the Server program it doesn't receive anything.

My code follows the example exactly, only modifying the port in both programs(11000) and in the client I changed the server IP to my public address.

Why am I seeing the data in my TCP listener but not in my Server program?


Solution

  • The problem was in the Server Code. When configuring the IPAddress it wasn't creating a correct one.

    I changed this line by this one and everything is working ok now:

    IPAddress ipAddress = new IPAddress(new byte[] { 192, 168, 1, 10 });
    

    Hope it help to another facing the same problem!