Trying to listen in a specified socket

Jun 15 2007 11:33 PM
hi, well i have to develop a chat using sockets, well i have a question, i can´t to a desired port, i don´t know what i am doing wrong, i think that the method "quieroEscuchar", something like "beginListen" it doesn´t triggered by the threadstart, please give me some advices to "open the port and listen": here is my code: namespace pepeiste { public partial class frmppal : Form { private TcpListener conchaacustica; private Thread hiloescuchar; private int mipuerto; private int tupuerto; private IPEndPoint miip; private string tuip; private bool leyendo; //private Socket sockescuchar; public frmppal() { InitializeComponent(); } private void btnoir_Click(object sender, EventArgs e) { try { int x = Convert.ToInt32(txtmipuerto.Text); //buscar un metodo para descubrir mi ip miip = new IPEndPoint(IPAddress.Any, x); conchaacustica = new TcpListener(miip); conchaacustica.Start(); hiloescuchar = new Thread(new ThreadStart(quieroEscuchar)); hiloescuchar.Start(); } catch (Exception error) { tuberia.Text = "Error proceso escuchaPuerto: " + error.Message; } } private void quieroEscuchar() { while (true) { Socket sockescuchar = conchaacustica.AcceptSocket(); if (sockescuchar.Connected) { x1.Text = "Escuchando..."; } else { x1.Text = "Desconectado..."; } } } } 

Answers (1)