# Include the socket header file, to provide TCP server methods. require 'socket' # Start the program. print "\n rbIdent, the Ruby Ident Daemon.\n\n" # Listen on port 113. daemon = TCPServer.new( 113 ) # Accept requests. while ( session = daemon.accept ) # Get the local-port and foreign-port. prefix = session.gets.strip # Print incoming. print " IN >> #{prefix}\n" # Get the OS specified. if ( ARGV[0] != nil ) # Use the argument given. osid = ARGV[0] else # Use a preset default (GEOS, a graphical operating system for the Commodore 64). osid = "GEOS" end # Get the ident username specified. if ( ARGV[1] != nil ) # Use the argument given. userid = ARGV[1] else # Use a preset default (ident). userid = "ident" end # Print out the ident response to the server. retstr = "#{prefix} : USERID : #{osid} : #{userid}\r\n" session.print "#{retstr}" # Print outgoing. print " OUT << #{retstr.strip}\n\n" # Close the session. session.close end