Dim d As Datagram
d=UDPSocket1.read
dim t as integer
dim nombre as string
dim topic as string
dim version as string
dim max as integer = 0
select case asc(mid(d.data, 1, 1))
case 3
dim i as integer = 8 // 1 BYTE PROTOCOLO, 2 BYTES PUERTO, 2 BYTES CUENTA, 2 BYTES PESO NOMBRE
while i < asc(mid(d.data, 6, 1)) + 8
nombre = nombre + mid(d.data, i, 1)
i = i + 1
wend ListBox1.addrow nombre
i = i + asc(mid(d.data, i, 1)) // REEMPLAZAR POR WHILE PARA OBTENER TOPIC i=i+2 i=i + 1 //lenguaje
i = i + asc(mid(d.data, i, 1)) // REEMPLAZAR POR WHILE PARA OBTENER VERSION i=i+2
dim cuenta as integer
dim j as integer = 0
dim ip as string
dim puerto as integer
cuenta = asc(mid(d.data, i, 1))
i =i +1
for j=1 to cuenta
ip = str(asc(mid(d.data, i, 1))) + "." + str(asc(mid(d.data, i+1, 1))) + "." + str(asc(mid(d.data, i+2, 1))) + "." + str(asc(mid(d.data, i+3, 1)))
puerto = asc(mid(d.data, i+4, 1)) + asc(mid(d.data, i+5, 1)) * 256
if max < 500 then
Dim dd as new Datagram
dd.Port=puerto
dd.Address=ip
dd.Data=chr(2)
UDPSocket1.SendToSelf=FALSE
UDPSocket1.Write dd
end if
max = max + 1
i=i+6
next
end select
No hay comentarios:
Publicar un comentario