B4J Question Mixing HTML and UDP connections in the same B4J server

CR95

Active Member
Licensed User
I slightly modified the tutorial B4J Tutorial [Server] Building web servers with B4J
https://www.b4x.com/android/forum/threads/server-building-web-servers-with-b4j.37172/

When a browser sends a command (http://ServerIP:ServerPort/ToDo?command), I added a "ToDoHandler" which returns a response using
B4X:
Private Sub SendRetourHTML(FirstLine As String,req As ServletRequest, resp As ServletResponse)
    resp.ContentType = "text/html"
    resp.Write(FirstLine)
End Sub
and the browser correctly shows the response.

I then added in the same server an UDP exchange with a second B4J application ; this exchange correctly works in a stand alone mode.

Issue is when I add the UDP exchange (with a WAIT FOR) between the reception of an HTML command and the return of the response. My final response does not get to the browser. I just get a blank page.

I found another thread (Casting an object?) where Erel wrote:
The problem is that the response is committed at the end of the HandleRequest event. You cannot later send anything. This means that you cannot send a http request at that point.

Consider implementing a real http server with B4J. It is much more powerful.

I am not sure it is the same issue : if I send a DB request to my server, the DB response correctly returns to the calling program !

Anyway, how can I return an HTML response to the sender after a WAIT FOR in the Handle Request?
 
Top