Hello world/Web server: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: defined 'client' outside the while condition)
Line 1,252: Line 1,252:
# start listening for incoming connections
# start listening for incoming connections


while(var client = sock.accept){
var client;
while (client = sock.accept) {
client.print ("HTTP/1.1 200 OK\r\n" +
client.print ("HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
Line 1,268: Line 1,269:
) || die "Could not create socket: #{$!}";
) || die "Could not create socket: #{$!}";


while (var client = sock.accept...) {
var client;
while (client = sock.accept...) {
client.print ("HTTP/1.1 200 OK\r\n" +
client.print ("HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +