Tried that--no errors
Hi Erel,
I did as you suggest. There are no error messages.
This is the VB.NET code which works:
Sub UDPstart()
Dim t As New Threading.Thread(AddressOf listen)
t.IsBackground = True
t.Start()
End Sub
Sub UDPend()
If theSocket IsNot Nothing Then theSocket.Close()
If beaconSocket IsNot Nothing Then beaconSocket.Close()
End Sub
Private Sub listen()
theSocket.Bind(ipep)
Dim beaconEP As New IPEndPoint(IPAddress.Any, 9131)
beaconSocket.Bind(beaconEP)
Dim ip As IPAddress = IPAddress.Parse("239.255.250.250")
'Dim sendEP As New IPEndPoint(ip, 9132)
beaconSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, New MulticastOption(ip, IPAddress.Any))
Dim temp As String = ""
Try
Do
'Dim b() As Byte = beaconSocket.Receive(beaconEP)
Dim b(255) As Byte
beaconSocket.Receive(b)
temp = System.Text.Encoding.UTF8.GetString(b)
If temp <> "" Then
If ParseGCInfo(temp) Then 'get once at start up
Exit Do
End If
End If
Loop
Catch ex As Exception
theSocket.Close()
beaconSocket.Close()
End Try
End Sub
Function ParseGCInfo(args As String) As Boolean
' The beacon message has the following format:
'AMXB<-UUID=GlobalCache_000C1E024239><-SDKClass=Utility>
'<-Make=GlobalCache><-Model=iTachWF2IR><-Revision=700-1001-10>
'<-Pkg_Level=GCPK001><-Config-URL=http://192.168.1.100.><-PCB_PN=025-0026-06>
'<-Status=Ready>
If Not args.StartsWith("AMXB") Then 'not an itach
Return False
End If
Dim i As Integer = InStr(args, "http://")
If i > 0 Then
args = Right(args, Len(args) - i - 6)
Dim j As Integer = InStr(args, ">")
ITACH_IP = Left(args, j - 1)
Return True
Else
Return False
End If
End Function