Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2009, 22:56
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Detectar tramas.

Hola de nuevo.

Quiero que me lleguen ciertas tramas diferentes al servidor con el cual se muestra el código abajo.
Código:
UdpClient udpClient = new UdpClient(int.Parse(textBox_Puerto.Text)); // AQUÍ.
                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());
                }
Las Tramas se llama:
M1: ON
M1: OFF

M2: ON
M2: OFF

M3: ON
M3: OFF

M4: ON
M4: OFF
Como verán, si llega esta trama exactamente de esa manera, por ejemplo: M1: ON, si el servidor lo detecta, que lo guarde en una variable String o cualquier otro, pero que la guarde.

¿Cómo puedo hacer eso?

Intené justo debajo del código anterior algo de esto, pero no me funciona.
Código:
Byte[] M1 = udpClient.Receive(ref RemoteIpEndPoint);
                    string returnData2 = Encoding.ASCII.GetString(M1);
                    radioButton_M1.Checked.GetTypeCode(M1);

Luego ya seguiré algo de esto:
http://msdn.microsoft.com/es-es/library/06tc147t.aspx

Cuando detecta exactamente cada una de esas tramas mencionadas arriba, hace una acción.

Adiós.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar