Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am fairly new to IPC with sockets and expect this issue is a simple one to resolve.

I'm trying to understand why I cannot get this example script from perldoc perlipc to run on my Ubuntu setup:

#!/usr/bin/perl -w
use IO::Socket;
$remote = IO::Socket::INET->new(
                                 Proto    => "tcp",
                                 PeerAddr => "localhost",
                                 PeerPort => "daytime(13)",
                               )
          || die "can't connect to daytime service on localhost";

while (<$remote>) { print }

The script dies because the TCP client cannot be established.

Running $ less /etc/services shows me that daytime(13) is defined. What could be wrong here?

share|improve this question
1  
Renan's answer is correct. The example was added to the perl documentation in 1997, when the mood on the Internet was "services are cool! Let's run all of them!" and has only received minor cosmetic updates since then. It would be hard to write a modern version; there just aren't any universally available TCP ports with dead-simple protocols like "daytime" on them any more. –  Alan Curry Jul 28 '12 at 1:47
    
What's your linux distribution ? If you don't have this service listening on localhost, how could you possibly connect to it. –  warl0ck Sep 13 '12 at 1:49
add comment

1 Answer 1

Are you running anything that provides a daytime service? From Wikipedia:

On UNIX-like operating systems a daytime server is usually built into the inetd (or xinetd) daemon. The service is usually not enabled by default. It may be enabled by adding the following lines to the file /etc/inetd.conf and telling inetd to reload its configuration.

 daytime   stream  tcp     nowait  root    internal
 daytime   dgram   udp     wait    root    internal

Thus you have to enable daytime service in the inetd.conf.

share|improve this answer
    
I don't seem to have x?inetd.conf under /etc. Is there an alternative way to do this? –  Zaid Jul 28 '12 at 7:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.