rjsaulakh has asked for the wisdom of the Perl Monks concerning the following question:

the follwoing daytime client program is not giving me the o/p

its running fine and there are no errors to please help me

#!/bin/usr/perl -w use strict; use Socket; use constant DEFAULT_ADDR => '127.0.0.1'; #use constant DEFAULT_ADDR => '192.168.1.54'; use constant PORT => 13; use constant IPPROTO_TCP => 6; my $address = shift || DEFAULT_ADDR; my $packed_addr = inet_aton($address); my $destintaion = sockaddr_in (PORT, $packed_addr); socket(SOCK,PF_INET,SOCK_STREAM,IPPROTO_TCP) or die " cant make socket + : $!" or die "cant connect : $!"; print <SOCK>;

Replies are listed 'Best First'.
Re: perl socket
by gaal (Parson) on Jan 24, 2005 at 06:04 UTC
    socket(SOCK,PF_INET,SOCK_STREAM,IPPROTO_TCP) or die " cant make socket + : $!" or die "cant connect : $!";
    Looks like you forgot to actually connect()?

    (For most practical applications, IO::Socket::INET is probably going to be easier to use. Of course if you're learning TCP/IP you may want to start with the low-level stuff anyway.)

Re: perl socket
by mkirank (Chaplain) on Jan 24, 2005 at 06:24 UTC
    Check out the Example mentioned in Oreilly book
    Here
Re: perl socket
by hsinclai (Deacon) on Jan 24, 2005 at 13:45 UTC
    To get the destination IP address from a command line argument you'd have to use
    my $address = shift @ARGV || DEFAULT_ADDR;

      Eh, no. shift || DEFAUTL_ADDR will do just fine, as a trivial example would have shown:
      $ perl -wle 'use constant DEFAULT_ADDR => "127.0.01"; my $address = shift || DEFAULT_ADDR; print $address' 192.168.1.1 192.168.1.1
      It's always wise to test your code before giving advice, but it's quite unwise to *not* test code you're claiming needs to be done differently.