'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private controller As GpioController
Private Pin5 As GpioPinDigitalOutput
Dim AStreams As AsyncStreams
Dim server As ServerSocket
Dim Socket1 As Socket
End Sub
Sub AppStart (Args() As String)
controller.Initialize
Pin5.Initialize(5, True)
server.Initialize(8899, "Server")
server.Listen
Log("MyIp = " & server.GetMyIP)
StartMessageLoop
End Sub
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
Log("Connected")
Pin5.Blink(100)
Socket1 = NewSocket
AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream, "AStreams")
'AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
Else
Log(LastException.Message)
End If
server.Listen
End Sub
Sub AStreams_NewData (buffer() As Byte)
Dim msg As String
msg = BytesToString(buffer, 0, buffer.Length, "UTF8")
Log(msg)
End Sub
Sub AStreams_Error
Log(LastException.Message)
End Sub