HTTP Server as Console App

I have created a module from the sample HTTP Web server.

If I create a new desktop application and add the HTTP module, it works fine and pages are served

If I create a console application using the same HTTP Module and execute it, the web page seems to connect, however it will wait forever trying to load the page and never returns anything.

How can I resolve this ?

Just a guess, but try adding this to the end of the App.Run event:

   While True
      DoEvents()
   Wend

Console applications don’t have a default event loop like GUI apps do. If you’re using event-based classes like a socket, you need to pump the event loop manually.

Thanks Andrew, but I already have a loop to keep the console application running.

Andrew;

I had this loop:

  do   
    #if TargetMachO then
      dim EventRecord as New MemoryBlock(100)
      declare function WaitNextEvent lib "Carbon" (eventmask as integer, EventRecord as Ptr, sleep as integer, mouse as integer) as Boolean
      call WaitNextEvent(0,EventRecord,1,0)
    #Else
      app.DoEvents
    #EndIf   
  Loop Until 1 = 0

and it would not work, however your simple loop:

 While True
      DoEvents()
   Wend

Does work - Thanks !

You know you can just do:

Do ... Loop

Right? No condition checking, just a nice endless loop.