Jump to content

Hello world/Web server: Difference between revisions

m
m (Fixed capitalization)
Line 154:
 
=={{header|BaCon}}==
Requires BaCon 4.2 or higher.
<lang qbasicbacon>' Define HTTP constants
CONST New$ = CHR$(13) & NL$
CONST Sep$ = CHR$(13) & NL$ & CHR$(13) & NL$
Line 165 ⟶ 166:
' Ignore child signals to avoid zombie processes
SIGNAL SIG_IGN, SIGCHLD
 
' Open listening port
OPEN Ip$ & ":8080" FOR SERVER AS mynet
 
' Keep receiving requests
WHILE TRUE
 
' Handle for newly incoming connection
' Open listening port
OPENfd Ip$ & ":8080" FOR SERVER AS= ACCEPT(mynet)
 
' Incoming connection -> create background process
Line 180 ⟶ 184:
' Get the request
REPEAT
RECEIVE dat$ FROM mynetfd
PRINT dat$
UNTIL RIGHT$(dat$, 4) = Sep$
 
' Reply that we're OK
SEND "HTTP/1.1 200 Ok" & New$ & "Content-Length: " & STR$(LEN(Msg$)) & Sep$ & Msg$ TO mynetfd
 
' Close connection
Line 191 ⟶ 195:
 
' End this process
ENDENDFORK
 
' We are in the parent
ELIF spawn > 0 THEN
 
' Close connection in parent
CLOSE SERVER mynet
 
ENDIF
WEND</lang>
</lang>
 
=={{header|BBC BASIC}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.