Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2009, 16:12
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
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