LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 12-16-2006, 11:49 AM   #1
eerok
Member
 
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:
Code:
#!/usr/bin/perl
# 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, 09:07 AM   #2
mcummings
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, 12:03 PM   #3
eerok
Member
 
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.
 
  


Reply

Tags
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 02:10 PM
Preauthentication fails with pam_krb5.so on debian edgood1 Linux - Software 0 03-07-2006 11:58 AM
Debian-Sarge never fails to surprise me........ Monkey 9 Debian 7 12-08-2005 07:40 AM
New Debian kernel fails to compile rickenbacherus Linux - Software 1 07-19-2003 09:56 AM
perldoc prisoner Programming 2 06-09-2003 07:57 PM


All times are GMT -5. The time now is 08:07 PM.

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