Reason for specified Error Occurence

Discussion in 'Perl Misc' started by Ranjit, May 10, 2007.

  1. Ranjit

    Ranjit Guest

    Hi Perl pals,

    Could any one let us know the reason why the below error is showing
    from this code.

    ERROR :

    Use of uninitialized value in subroutine entry at C:/Perl/lib/
    Socket.pm line 373.
    Bad arg length for Socket::pack_sockaddr_in, length is 0, should be 4
    at C:/Perl/lib/Socket.pm line 373.


    #!/usr/bin/perl
    use Socket;
    $proto = getprotobyname('tcp');
    $domain = PF_INET;
    $type = SOCK_STREAM;
    socket(CLIENT,$domain,$type,$proto);

    $port = 0 ;
    $ipaddr = INADDR_ANY;
    $sockaddr = sockaddr_in($port,$ipaddr);
    bind(CLIENT,$sockaddr);
    print "sathi";

    $host = 'www.yahoo.com';
    $port = getservbyname('http','tcp');
    $ip_addr= inet_aton($host);
    $sockaddr = sockaddr_in($port,$ip_addr);
    connect(CLIENT,$sockaddr);

    Thanks in Advance

    Regards,
    Ranjit
    Ranjit, May 10, 2007
    #1
    1. Advertising

  2. Ranjit

    Dr.Ruud Guest

    Ranjit schreef:

    > Could any one let us know the reason why the below error is showing
    > from this code.
    >
    > ERROR :
    >
    > Use of uninitialized value in subroutine entry at C:/Perl/lib/
    > Socket.pm line 373.
    > Bad arg length for Socket::pack_sockaddr_in, length is 0, should be 4
    > at C:/Perl/lib/Socket.pm line 373.
    >
    >
    > #!/usr/bin/perl


    Missing:

    use strict;
    use warnings;


    > use Socket;
    > $proto = getprotobyname('tcp');
    > $domain = PF_INET;
    > $type = SOCK_STREAM;


    printf "proto:%s, domain:%s, type:%s\n",
    $proto, $domain, $type;

    > socket(CLIENT,$domain,$type,$proto);


    Missing: test for succes.


    > $port = 0 ;
    > $ipaddr = INADDR_ANY;
    > $sockaddr = sockaddr_in($port,$ipaddr);


    printf ...

    > bind(CLIENT,$sockaddr);


    test ...

    > print "sathi";
    >
    > $host = 'www.yahoo.com';
    > $port = getservbyname('http','tcp');
    > $ip_addr= inet_aton($host);


    printf ...

    > $sockaddr = sockaddr_in($port,$ip_addr);


    printf ...

    > connect(CLIENT,$sockaddr);


    test ...

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, May 11, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dustin D.
    Replies:
    1
    Views:
    11,141
  2. Mr Ideas Man

    Occurence of Char!

    Mr Ideas Man, Feb 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    480
    Terry Burns
    Feb 10, 2006
  3. natG
    Replies:
    4
    Views:
    9,653
  4. Roland
    Replies:
    1
    Views:
    1,527
    Oleg Tkachenko
    Sep 25, 2003
  5. Armin Wagenknecht
    Replies:
    0
    Views:
    375
    Armin Wagenknecht
    May 4, 2004
Loading...

Share This Page