On Mon, 15 Oct 2001 04:23:49 +0900, ptkwt / shell1.aracnet.com (Phil Tomson) wrote: > In article <20011013131947.147b876f.mike / lepton.fr>, > Michael Witrant <mike / lepton.fr> wrote: > > [inetd: STDIN as a Socket] > > When you get this all working, could you post the code and the line in the > inetd.conf file that makes it all work? I wrote a simple daemon to send the current local time (see below). It logs the requests through syslog[1]. I changed Matju's Socket#addr to return the ip address as string. The line in inetd.conf: sample_time stream tcp nowait nobody /usr/local/bin/sample_time_daemon sample_time_daemon The sample_time port must be defined in /etc/services. [1] http://www.ruby-lang.org/en/raa-list.rhtml?name=Syslog Mike. --- sample_time_daemon --- #!/usr/local/bin/ruby require 'socket' require 'syslog' class Socket def port # assumes ipv4 d=getpeername d[2]*0x100+d[3] end def addr # assumes ipv4 d=getpeername (4...8).map{|x|d[x]}.join('.') end end time = Time.now.strftime('%Y-%m-%d %H:%M:%S') remote_address = Socket.for_fd(0).addr STDERR.puts time Syslog.open "sample_time_daeon" do |syslog| syslog.log Syslog::LOG_INFO, "Sent time to #{remote_address}: #{time}" end