# Copyright 2002 Combex, Inc. under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ # Derived from e/scripts/webServer/webServerSocket80.e def makeParseFunc := () def server(stderr, makeFileFeeder, makeOutputStreamWriter, serverSocket) :void { try { while (true) { stderr.println("accepting") def socket := serverSocket.accept() try { def out := makeOutputStreamWriter(socket.getOutputStream()) def ins := ( ( socket.getInputStream())) def pf := makeParseFunc(makeFileFeeder("", ins, null), [].asMap(), stderr) stderr.println(" reading") while (pf() =~ expr :notNull) { stderr.println(` read $expr`) out."write(char[])"(E.toString(expr)) out.flush() } stderr.println(` closed`) } catch p { stderr.println(` error while handling client: $p`) } } } finally { serverSocket.close() } }