Hello world/Web server: Difference between revisions

Line 471:
 
=={{header|D}}==
Using sockets only, also shows use of heredoc syntax, and std.array.replace, .
''If you copy from this page, be careful with extraneous spaces on the empty lines in the heredoc''.
and casting to bool to satisfy the while conditional.
 
<lang D>import std.socket, std.array;
import std.socket, std.array;
 
ushort port = 8080;
Line 486 ⟶ 485:
Socket currSock;
 
while (cast(bool)null !is (currSock = listener.accept())) {
currSock.sendTo(replace(q"EOF
HTTP/1.1 200 OK
Line 492 ⟶ 491:
 
<html>
<head><title>Hello, world!</title></head>
<body>HelloGoodbye, worldWorld!</body>
</html>
EOF", "\n", "\r\n"));
Anonymous user