#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
'https://www.b4x.com/b4j/help/jnetwork.html#serversocket
Private ss As ServerSocket
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
ss.Initialize(80,"ss") 'Port must be free and not used by any WebServer like MS IIS,Apache,Jetty
'ss.InitializeSSL
ss.Listen
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub ss_NewConnection(Successful As Boolean, NewSocket As Socket)
'https://www.w3schools.com/tags/tag_form.asp
Dim st As InputStream
st = NewSocket.InputStream
Dim buffer(1024) As Byte
Dim count As Int =0
Do Until count = -1
count = st.ReadBytes(buffer, 0, buffer.length)
If count > 0 Then Log(BytesToString(buffer,0, count , "UTF-8"))
Loop
End Sub