Quiero que me lleguen ciertas tramas diferentes al servidor con el cual se muestra el código abajo.
Código:
Las Tramas se llama: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()); }
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.