/tutorial/net/papoose.e

http://github.com/tybor/Liberty · Specman e · 57 lines · 38 code · 8 blank · 11 comment · 0 complexity · 77cbbf044187b8e2c1b4caa9ddbc8777 MD5 · raw file

  1. class 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. create {ANY}
  14. make
  15. feature {ANY}
  16. make
  17. local
  18. host: LOCALHOST; tcp: TCP_ACCESS; server: HTTP_SERVER
  19. do
  20. create host.make
  21. create tcp.make(host, 8080, True)
  22. tcp.set_address_reuse(True) -- to be able to reuse a port in TIME_WAIT state
  23. create server.make(agent error_handler(?), agent new_connection)
  24. server.set_logger(agent log(?))
  25. server.start(tcp)
  26. end
  27. log (msg: ABSTRACT_STRING)
  28. do
  29. access.put_line(msg)
  30. access.flush
  31. end
  32. error_handler (text: STRING)
  33. do
  34. error.put_line(text)
  35. error.flush
  36. end
  37. new_connection: PAPOOSE_CONNECTION
  38. do
  39. create Result.make(Void)
  40. end
  41. access: TEXT_FILE_WRITE
  42. once
  43. create Result.connect_for_appending_to(once "access.log")
  44. end
  45. error: TEXT_FILE_WRITE
  46. once
  47. create Result.connect_for_appending_to(once "error.log")
  48. end
  49. end -- class PAPOOSE