I have some kind of problem and I can't check this at home if its working or not. Here is the code

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Net.Security;

class Program
{
    private static IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
    private static int port = 6000;
    private static string data = null;

    static void Main(string[] args)
    {
        Thread thread = new Thread(new ThreadStart(receiveThread));
        thread.Start();
        Console.ReadKey();
    }

    public static void receiveThread()
    {
        while (true)
        {
            TcpListener tcpListener = new TcpListener(ipAddress, port);
            tcpListener.Start();

            Console.WriteLine("Waiting for connection...");

            TcpClient tcpClient = tcpListener.AcceptTcpClient();

            Console.WriteLine("Connected with {0}", tcpClient.Client.RemoteEndPoint);

            while (!(tcpClient.Client.Poll(20, SelectMode.SelectRead)))
            {
                NetworkStream networkStream = tcpClient.GetStream();
                StreamReader streamReader = new StreamReader(networkStream);

                data = streamReader.ReadLine();

                if(data != null)
                    Console.WriteLine("Received message: {0}", data);
            }
            Console.WriteLine("Dissconnected...\n");
            tcpListener.Stop();
        }
    }
}

I have a simple program as well to connect to this and then send a string with data. It works fine on localhost but there is a problem when I'm trying to connect with a different coputer.

I even turned off the firewall on my PC and router, as I did on my friend's laptop. Every time I have tried to connect, his computer refused connection. Maybe I'm doing something wrong?

Of course, ipAddress is a local address now since it's only working with that at the moment. Any suggesti

Edit
Report