There seems to be a problem with sending UDP Packets. My app sends the same packet every second using a timer. However when I run it only one packet gets sent. I made a simple test app and I get the same results.I am using B4i ver. 4.01 Please help.
B4X:
'Code module
#Region Project Attributes
#ApplicationLabel: UDP Test
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 7
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Dim Timer1 As Timer
Dim bytes1() As Byte = Array As Byte (0xFE, 0x02, 0x01,0xfe,0x02)
Dim UDPSocket1 As UDPSocket
Dim Packet1 As UDPPacket
End Sub
Private Sub Application_Start (Nav As NavigationController)
'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Timer1.Initialize ("Timer1",1200)
Timer1.Enabled = True
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
End Sub
Sub Timer1_Tick
Dim UDPSocket1 As UDPSocket
UDPSocket1.Initialize("UDP1",2107,180) 'event name, port, buffer)
Packet1.Initialize(bytes1, "192.168.16.254",2107)
UDPSocket1.Send(Packet1)
End Sub
Last edited: