#Region Project Attributes
#ApplicationLabel: UDP Connection
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim UDPSocket1 As UDPSocket
Dim send_packet As UDPPacket
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim data() As Byte
Dim ip_box As EditText
Dim rx_msg As EditText
Dim rx_port As EditText
Dim tx_msg As EditText
Dim tx_port As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub start_Click
UDPSocket1.Initialize("UDP", rx_port.Text, 8000)
End Sub
Sub send_Click
Dim msg As String
msg = tx_msg.Text
data = msg.GetBytes("UTF8")
send_packet.Initialize(data,ip_box.Text,tx_port.Text)
UDPSocket1.Send(send_packet)
End Sub
Sub UDP_PacketArrived(Packet As UDPPacket)
Dim msg As String
msg = BytesToString(Packet.data, Packet.Offset, Packet.Length, "UTF8")
rx_msg.Text = rx_msg.Text & msg
rx_msg.Text = rx_msg.Text & Chr(13)
End Sub