Can't establish Bittorrent connection
<p>I'm trying to make a bittorrent client, I installed uTorrent because I'm trying to make a connection in the same pc using a torrent file that I created using uTorrent, this is my handshake message...</p>

<pre><code>namespace WaveTorrentV1.src.Client.Messages
{
class Handshake
{
    private const int protocol = 20;
    private const int reserved = 8;
    private const int hash = 20;
    private const int peer_ids = 20;
    private const int total = protocol + reserved + hash + peer_ids;

    private byte[] complete_message = new byte[total];

    public Handshake(byte[] sha1, string peer_id)
    {
        int counter = 0;
        complete_message[counter] = 19;
        counter++;

        int i = 0;

        foreach (char chr in "BitTorrent protocol")
        {
            complete_message[counter] = (byte)chr;
            counter++;
        }

        counter += 8;

        if (sha1.Length != 20)
        {
            throw new HandshakeException("length of the info_hash different of 20 bytes");
        }

        foreach (byte byt in sha1)
        {
            complete_message[counter] = byt;
            counter++;
        }

        if (peer_id.Length != 20)
        {
            throw new HandshakeException("length of peer_id different of 20 chars");
        }

        foreach (char chrs in peer_id)
        {
            complete_message[counter] = (byte)chrs;
            counter++;
        }
    }

    public byte[] getMessageBytes()
    {
        return complete_message;
    }
}
}
</code></pre>

<p>and this is the code I'm using to establish a connection</p>

<pre><code>TorrentReader file = new TorrentReader("C:\\test10.torrent");
TcpClient client = new TcpClient();
client.Connect("127.0.0.1", 6888);
Stream st = client.GetStream();
Handshake message1 = new Handshake(file.getRawInfoHash(), "-WT1219-135729995916");
st.Write(message1.getMessageBytes(), 0, message1.getMessageBytes().Length);
st.Flush();
while (true)
{
     NetworkStream stream = client.GetStream();
     byte[] readed = new byte[1024];
     stream.Read(readed, 0, 1024);
     string result = System.Text.Encoding.ASCII.GetString(readed); //I'm using this because I like to know if I'm received some data
     st.Write(message1.getMessageBytes(), 0, message1.getMessageBytes().Length);
     st.Flush();
}
</code></pre>

<p>in the first loop of the while I'm not getting anything, in the second loop I get this exception:
<strong>Can not write data to the transport connection: connection was aborted by the software provided on your host computer.</strong></p>

<p>in what I'm failing???, because I don't think that uTorrent is dropping me the connection because the handshake message is correct, or not???
Thanks for read.
<strong>Note: the decode of the torrent (bencode) in runtime execution is correct</strong></p>
