Try this while(true) { Socket cs = s.accept(); cs.receive(new byte[1024]); cs.sendTo("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello World"); cs.close(); }
On Thu, Feb 9, 2012, at 07:31 PM, Nrgyzer wrote: > Hi guys, > > I wrote the following few lines: > > private { > > import std.socket; > > } > > void main() { > > Socket s = new TcpSocket(); > s.bind(new InternetAddress(80)); > s.listen(0); > > while(true) { > > Socket cs = s.accept(); > cs.sendTo("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello > World"); > cs.close(); > > } > > s.close(); > > } > > The code compiles successfully and I also the server also responses with > "Hello World", but when I reload the page I sometimes get the following > error (Firefox): "The > connection was reset" - I also often get the same error in other > browsers. Is there anything wrong with the code? > > Thanks in advance! > -- D