/tutorial/net/papoose.e
Specman e | 57 lines | 38 code | 8 blank | 11 comment | 0 complexity | 77cbbf044187b8e2c1b4caa9ddbc8777 MD5 | raw file
1class PAPOOSE 2 -- 3 -- PAPOOSE is not 4 -- Apache, 5 -- PAPOOSE 6 -- Object 7 -- Oriented, written for 8 -- Smart 9 -- Eiffel 10 -- 11 -- Well... PAPOOSE is just a very, very small HTTP server :-) 12 -- 13 14create {ANY} 15 make 16 17feature {ANY} 18 make 19 local 20 host: LOCALHOST; tcp: TCP_ACCESS; server: HTTP_SERVER 21 do 22 create host.make 23 create tcp.make(host, 8080, True) 24 tcp.set_address_reuse(True) -- to be able to reuse a port in TIME_WAIT state 25 create server.make(agent error_handler(?), agent new_connection) 26 server.set_logger(agent log(?)) 27 server.start(tcp) 28 end 29 30 log (msg: ABSTRACT_STRING) 31 do 32 access.put_line(msg) 33 access.flush 34 end 35 36 error_handler (text: STRING) 37 do 38 error.put_line(text) 39 error.flush 40 end 41 42 new_connection: PAPOOSE_CONNECTION 43 do 44 create Result.make(Void) 45 end 46 47 access: TEXT_FILE_WRITE 48 once 49 create Result.connect_for_appending_to(once "access.log") 50 end 51 52 error: TEXT_FILE_WRITE 53 once 54 create Result.connect_for_appending_to(once "error.log") 55 end 56 57end -- class PAPOOSE