Hello all follwing is the perl scrit.Which tries to create a socket.But whenever I run this progrem I am getting error like bCould not create socket: Connection refused.I think this statement is causing this problrm IO::Socket::INET.I think soket creataion is failure.Below is the program that cause this problem .I am running this script on linux machine 2.6.18 kernel and perl vesrion is v5.8.8 .Any help will be appreciate
#!/usr/bin/perl -w use strict; use lib "$ENV{CTI_BASE}/arches/lib"; use TestClass; use Getopt::Std; use IO::Socket::INET; use MfwTemplate; #Inside of MfwTemplate.pm are the default $cmdopts and @usage paramete +rs. #If other than the defaults are desired then enter those values here. #testSetUpAndExecute(\&execute_test,$cmdopts,\@usage); testSetUpAndExecute(\&execute_test); # you shouldn't have to change anything above this line, unless you're + adding more command line options # put your new test here sub execute_test { my ($test,%opts) = @_; my $status = "Pass"; my $sdpHeader = pack("CCCCN",0x30,1,1,1,23); my $sdpCmd = pack("CCCCnN",1,0,0x11,0x40,0,13); my $sdpData = pack("CNC8",0,64,1,2,3,4,5,6,7,8); my @header = unpack("CCCCN",$sdpHeader); printf("SDPHEADER: boardCab:%02x fragId:%02x fragTotal:%02x seqNum:%02 +x totalCount:%08x\n", $header[0],$header[1],$header[2],$header[3],$header[4]); my @cmd = unpack("CCCCnN",$sdpCmd); printf("SDPCMD: index:%02x modResp:%02x opEndSt:%02x status:%04x dataC +ount:%08x\n", $cmd[0],$cmd[2],$cmd[3],$cmd[4],$cmd[5]); my @d = unpack("CNC8",$sdpData); printf("SDPDATA: chain:%02x bitCount:%08x\n", $d[0],$d[1]); printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", $d[2],$d[3],$d[4],$d[5],$d[6],$d[7],$d[8],$d[9]); #Here i am not able to createing soket . my $sock_out = new IO::Socket::INET (PeerAddr => 'st04a', PeerPort => 5050, Proto => 'tcp',Type => SOCK_STREAM ); die "Could not create socket: $!\n" unless $sock_out; print $sock_out "$sdpHeader"; $sock_out->flush(); }

In reply to Could not create socket: Connection refused in perl by h3x

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.