I'm trying to use the code shown below to send my ip address to the broadcast address of the local wifi router. Note that receiving data using UDPSocket works OK. Only when sending do I get error 13. It's odd that this error is not trapped with try/catch. This same code works fine on Android devices. Using B4i 4.0 and IOS 10.3.3.
B4X:
Sub Process_Globals
Dim MyIP, Address as string
Dim broadcasttimer As Timer
Dim autodiscover2 As UDPSocket
Dim serializator As B4XSerializator
End Sub
Sub Start
MyIP = server.GetMyWifiIP
Address = us.GetBroadcastAddress
autodiscover2.Initialize("",11919, 100)
broadcasttimer.Initialize("BroadcastTimer", 3000)
broadcasttimer.Enabled = True
End Sub
Private Sub BroadcastTimer_Tick
If Address <> "" Then
Dim up As UDPPacket
up.Initialize(serializator.ConvertObjectToBytes(MyIP), Address, 11919)
autodiscover2.Send(up)
End If
End Sub