Foros del Web » Programación para mayores de 30 ;) » .NET »

Ayuda con introducir un valor.

Estas en el tema de Ayuda con introducir un valor. en el foro de .NET en Foros del Web. Hi. Quiero cambiar de puerto en un textBox en tiempo real en un server. ¿Se puede hacer? La verdad no lo consigo hacerlo funcionar. Código: ...
  #1 (permalink)  
Antiguo 15/05/2009, 16:12
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Ayuda con introducir un valor.

Hi.

Quiero cambiar de puerto en un textBox en tiempo real en un server. ¿Se puede hacer?

La verdad no lo consigo hacerlo funcionar.

Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;
using System.Threading;

namespace PC2_Server
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void serverThread()
        {
            //  UdpClient udpClient = new UdpClient(int.Parse(textBox_Puerto.Text)); // AQUÍ.
                UdpClient udpClient = new UdpClient(60000);
                while(true)
                {
                    IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
                    Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
                    string returnData = Encoding.ASCII.GetString(receiveBytes);
                    lbConnections.Items.Add(RemoteIpEndPoint.Address.ToString() + ": " +
                    returnData.ToString());
                }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Thread thdUDPServer = new Thread(new
            ThreadStart(serverThread));
            thdUDPServer.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            statusStrip1.Items[0].Text = DateTime.Now.ToLongTimeString();
            statusStrip1.Items[1].Text = (textBox_Puerto.Text.ToString());
        }
    }
}
El que quiere el código fuente completo y el PC1-Cliente para que puedan enviar tramas, se los mando por e-mail.

Goobye.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
  #2 (permalink)  
Antiguo 15/05/2009, 17:30
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 7 meses
Puntos: 87
Respuesta: Ayuda con introducir un valor.

errores generados o simplemente no te actualiza el puerto

// UdpClient udpClient = new UdpClient(int.Parse(textBox_Puerto.Text)); // AQUÍ.
UdpClient udpClient = new UdpClient(60000);


considera que esas 2 lineas (descomentadas o no) solo se alcanzan en la invocacion del hilo pero no durante su ejecucion.
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5
  #3 (permalink)  
Antiguo 15/05/2009, 22:49
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Respuesta: Ayuda con introducir un valor.

Gracias, ya corregí el fallo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:01.