Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-16-2006, 10:49 AM   #1
Registered: Nov 2005
Location: Canada
Distribution: Mint, Debian
Posts: 168

Rep: Reputation: 32
perldoc perlipc example fails, debian 4

I'm just curious why this example from the perl docs doesn't work. The service of course exists in /etc/services. I edited the code trivially to use warnings and strict, I read 'perldoc IO::Socket::INET', I've tried several variations, but it doesn't work no matter what I tried:
# local-001 - example from perlipc (perl 5.8.8)
use strict;
use warnings;
use IO::Socket::INET;

my $remote = IO::Socket::INET->new (
    Proto    => "tcp",
    PeerAddr => "localhost",
    PeerPort => "daytime(13)",
    or die "cannot connect to daytime port at localhost";
while (<$remote>) {print}
tale@hyute:~/00-perl$ ./local-001
cannot connect to daytime port at localhost at ./local-001 line 7.

It's not a big deal, however it helps when you're learning a language to be rigorous about why things fail ... and I'm just learning perl. I think there's a system-related reason why I can't access that socket ...
Old 12-17-2006, 08:07 AM   #2
LQ Newbie
Registered: Oct 2006
Location: Fredericksburg, Va, USA
Distribution: Gentoo
Posts: 9

Rep: Reputation: 0
unless you're running a daytime service (like ntp) locally and it's bound to localhost, this is bound to fail. On the upside, the fact that you get the "cannot connect to daytime port" means that it in fact did attempt to establish a socket call. Not so much a bad example as much as a poorly thought out one (depends too much on you having a particular service running).
Old 12-17-2006, 11:03 AM   #3
Registered: Nov 2005
Location: Canada
Distribution: Mint, Debian
Posts: 168

Original Poster
Rep: Reputation: 32
Ah, I thought it would be something like that. I also thought that I had ntp running, but since I've rebuilt the system lately, maybe I don't

In a sideways fashion, maybe it wasn't such a bad example, because now I know more about IO::Socket::INET than I would've if the example had succeeded right away.


perl, services, sockets

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Building DRBD into 2.6.17 Debian Fails technick Linux - Kernel 1 08-09-2006 01:10 PM
Preauthentication fails with on debian edgood1 Linux - Software 0 03-07-2006 10:58 AM
Debian-Sarge never fails to surprise me........ Monkey 9 Debian 7 12-08-2005 06:40 AM
New Debian kernel fails to compile rickenbacherus Linux - Software 1 07-19-2003 08:56 AM
perldoc prisoner Programming 2 06-09-2003 06:57 PM

All times are GMT -5. The time now is 05:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration