Example #1
0
 protected void AddCliConected(Socket handler)
 {
     try
     {
         string ip = IPAddress.Parse(((IPEndPoint)handler.RemoteEndPoint).Address.ToString()).ToString();
         int porta = ((IPEndPoint)handler.RemoteEndPoint).Port;
         this.conexao = new Conexoes();
         this.conexao.socket = handler;
         this.conexao.ip = ip;
         this.conexao.porta = porta;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro ao adionar cliente a conexões.");
         Console.WriteLine(ex.ToString());
     }
 }
Example #2
0
        public bool VerificaConexaoTcp()
        {
            bool hasProblem = false;
            bool part1, part2;

            part1 = this.conexao.socket.Poll(10, SelectMode.SelectRead);
            part2 = this.conexao.socket.Available == 0;

            if (part1 && part2)
            {
                //encerro a coneção
                EncerraConexaoTcp();
                this.conexao = null;
                hasProblem = true;
            }
            return hasProblem;
        }