views:

279

answers:

2

The IO Exception: "Unable to read data from the transport connection: An established connection was aborted by the software in your host machine."

The code has been copied from a tutorial and I'm sure that this error has something to do with my own machine. All of my firewalls, ESET and Windows, are off. The clients connect via port 55555.

edit:

Client

    static void Main(string[] args)
    {
        MakeClientCallToServer("test");
        MakeClientCallToServer("test2");
        MakeClientCallToServer("test3");

        // Now send a bunch of messages...
        string msg;
        for (int i = 0; i < 100; i++)
        {
            msg = string.Format(Thread.CurrentThread.CurrentCulture,
            "I'll not be ignored! (round {0})", i);
            ThreadPool.QueueUserWorkItem(new
            WaitCallback(MakeClientCallToServer), msg);
        }
        Console.WriteLine("\n Press any key to continue... ");
        Console.Read();
    }
    static void MakeClientCallToServer(object objMsg)
    {
        string msg = (string)objMsg;
        MyTcpClient client = new MyTcpClient(IPAddress.Loopback, 55555);
        client.ConnectToServer(msg);
    }

Server

    static MyTcpServer server;

    static void Main(string[] args)
    {
        ThreadPool.QueueUserWorkItem(RunServer);
        Console.WriteLine("Press esc to stop the server...");
        ConsoleKeyInfo cki;
        while (true)
        {
            cki = Console.ReadKey();
            if (cki.Key == ConsoleKey.Escape)
            {
                break;
            }
        }
    }

    static void RunServer(object stateInfo)
    {
        //Initiate the server)
        server = new MyTcpServer(IPAddress.Loopback, 55555);
        server.Listen();
    }

I've already made classes named MyTcpServer and MyTcpClient to handle all of the common connections, threading, etc.

A: 

you can try using Wireshark to capture the data flow to see what happened.

Benny
A: 

Any possibility we can see some code?

You're right that the most common reason for this error is something blocking on your machine, so turning off all of that stuff is a great first-step. Since it's still happening though, can you load up Wireshark to see what's going on with your packets?

mrduclaw