i need some help with this exception here's the code, i can't find a good solution for this so please give some help....
heres the code. public void IniciaEscuta() { // Cria o Sockect que será responsável por receber as requisições do GateWay listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.controladorThread = new ManualResetEvent(false); string result = string.Empty; this.Continua = true; try { IPHostEntry hostInfo = Dns.GetHostEntry(Dns.GetHostName()); result = hostInfo.AddressList.Where(i => i.AddressFamily.Equals(AddressFamily.InterNetwork)).First().ToString(); ManagerLog.Writelog("IniciaEscuta(): " + result, "Debug"); IPAddress localIPAddress = IPAddress.Parse(result); IPEndPoint ep = new IPEndPoint(localIPAddress, porta); ManagerLog.Writelog("IniciaEscuta() " + Environment.NewLine + "IPEndPoint: " + ep.Address.ToString() + Environment.NewLine + "Porta: " + porta, "Debug"); TcpListener listener = new TcpListener(ep); //listenSocket.Bind(ep); // listenSocket.Listen(int.Parse(ConfigurationManager.AppSettings["MaxListenInQueue"].ToString())); while (this.Continua) { controladorThread.Reset(); listener.Start(int.Parse(ConfigurationManager.AppSettings["MaxListenInQueue"].ToString())); listener.BeginAcceptTcpClient(new AsyncCallback(Escuta_Callback), listener); //listenSocket.BeginAccept(new AsyncCallback(Escuta_Callback), listenSocket); controladorThread.WaitOne(); } } catch (Exception ex) { ManagerLog.Writelog(ex.Message, "Erro: "); listenSocket.Close(); } } private void Escuta_Callback(IAsyncResult ar) { controladorThread.Set(); if (!this.Continua) return; TcpClient s = null; StateObject so = new StateObject(); #region Conclui a conexão com o cliente. try { s = (TcpClient)ar.AsyncState; s.EndConnect(ar); so.workSocket = s; } catch (SocketException se) { ManagerLog.Writelog("Erro ao concluir a conexão em Escuta_Callback()." + Environment.NewLine + se.Message, "Erro"); } catch (Exception e) { ManagerLog.Writelog("Erro ao concluir a conexão em Escuta_Callback()." + Environment.NewLine + e.Message, "Erro"); } #endregion -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to dotnetdevelopment@googlegroups.com To unsubscribe from this group, send email to dotnetdevelopment+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net