ID:259615
 
After extensive searching experimentation, I've managed to get Byond programs to run in CGI mode under my _Windows_ webserver.
I know the dmb is being executed, (I've been able to have it write out to a file) but no matter what I do, I cannot get anything output back to the web browser, every attempt I've made has resulted in nothing but a blank empty page...

If anyone has any ideas, or suggestions that could help me, I'd would appreciate it greatly. Thank you.
Ummm, if your running windows, good luck, i think digi mouse tryed it, and couldnt find a way.
In response to Scoobert
Well, the Windows version DreamDaemon DOES accept the -CGI option, so if it can't handle CGI properly it should be considered a bug with Byond...
In response to Kevin Kitsune
Are you talking about running a web server using BYONDCGI or just using it in a game?
In response to Scoobert
Using BYOND CGI on a webserver. I've gotten it to execute the dmb, when I point my browser to the .dmb file DreamDaemon executes it in CGI mode.
I've been able to have it create a file, but I can't seem to get any output back to the browser, I just get a blank page.

I've tried several examples, tried with and without the Byond CGI lib, nothing is output to the browser, despite the fact that the dmb file is being executed properly.
In response to Kevin Kitsune
Have you tried running the dmb from the DOS command line to see if it outputs anything? If that works, then I would guess it's something with the web server software (I have no experience with that under Windows). If not, it's either in your code or as you said, the BYOND CGI mode under Windows.

You're placing your code under CGI/Topic() and using usr << browse("Html text") to output, right?
In response to Air Mapster
Yes I have tried running it from dos command line, nothing is output. Not even HTML headers...

Also, I am outputting via usr << browse("text") from the CGI/Topic() proc, I've also tried outputting from several other procs as well and still nothing appears.
In response to Kevin Kitsune
I just tried a little test, and you're right. Nothing is output to the terminal but the procs do run, as can be verified with text2file(). I believe the CGI output is done internally using a simple printf() statement. So either Windows ignores this because DreamDaemon was compiled as a gui application (wouldn't surprise me, I have zero experience with Windows programming in this regard) or the Windows version doesn't have that particular code compiled in.

I'll mention it to Tom when I see him this weekend.
In response to Air Mapster
I see... I was afraid of that. I guess I'll have to hold off on this for now, thanks.
In response to Kevin Kitsune
Well, perhaps there is a workaround, if your webserver will execute DOS batch files. I redirected all output to a text file, and created a batch file to run the program and "type" the resulting text file:

cgi.dm
var/of = "testout.txt"

CGI
proc/HttpHeader()
text2file("Content-type: text/html", of)
text2file("", of)

Topic()
fdel(of)
usr << "" // to trigger HttpHeader()
text2file("<html><body><h1>Test!</h1></body></html>", of)


cgi.bat
@echo off
"C:\Program Files\BYOND\bin\dreamdaemon.exe" "test.dmb" "2000" "-CGI" "-logself"
type testout.txt


Of course, if you want to use BYOND CGI longterm (or switch to a unix platform later on), it's probably best to wait for proper Windows support.
In response to Air Mapster
Air Mapster wrote:
I just tried a little test, and you're right. Nothing is output to the terminal but the procs do run, as can be verified with text2file(). I believe the CGI output is done internally using a simple printf() statement. So either Windows ignores this because DreamDaemon was compiled as a gui application (wouldn't surprise me, I have zero experience with Windows programming in this regard) or the Windows version doesn't have that particular code compiled in.

Well, it appears that both of your hypotheses are correct. Even in CGI mode DD executes as a GUI app; it just starts up and shuts down quickl). We don't use printf() in that case, but even when we do, Windows doesn't care. (I just confirmed that). I'm pretty sure we can workaround this with a shell call, but there's probably a cleaner solution. Ideally, I'd like to have a console version of DD, but the last time I looked into this I couldn't figure out how to access the socket functions without having a window.

Anyway, hopefully we can holdup on this request for a while. I want to get the next release out and then start attending to some of these bugs.
In response to Tom
Tom, can you e-mail me a tutorial on using Dantom HostServer?
In response to Wolf01
There's a tutorial included with it.