Created
July 15, 2009 10:43
-
-
Save oneup/147638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# Generic TCP Server Example | |
require "GServer" | |
class Root < GServer | |
def initialize(port=10001, *args) | |
super(port, *args) | |
end | |
def serve(io) | |
io.puts(Time.now.to_i) | |
end | |
end | |
server = Root.new | |
server.audit = true # Turn logging on. | |
server.start | |
# *** Now point your browser to http://localhost:10001 to see it working *** | |
# See if it's still running. | |
GServer.in_service?(10001) # -> true | |
server.stopped? # -> false | |
# Shut the server down gracefully. | |
server.shutdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment