After modifications my script will look like
#usr/bin/perl use strict; use warnings; use IO::Socket; $| = 1; my $client; my $socket= new IO::Socket::INET( LocalPort => '4500', Proto => 'tcp', Listen => 1, Reuse => 1 ); die "Couln't open socket: $!" unless $socket; while(1) { $client = $socket->accept() or die sprintf "ERRRR(%d)(%s)(%d)( +%s)", $!,$!,$^E,$^E; print "Socket Accepted:$client....\n"; $client->autoflush(1); my $addr = $client->peerhost(); my $port = $client->peerport(); print "Got Connection from \"$addr\" at port $port\n"; while( <$client> ) { print "$client" } }
When I run this script I'm getting the error as
Couln't open socket: Address already in use at servertest.pl line 14. FYR
[root@station34 Socket]# netstat -anp | grep 4500 tcp 0 0 192.168.0.34:4500 0.0.0.0:* + LISTEN 22948/nco_objserv tcp 0 0 192.168.0.34:32997 192.168.0.34:4500 + ESTABLISHED 22990/nco_p_syslog tcp 0 0 192.168.0.34:32996 192.168.0.34:4500 + ESTABLISHED 22991/nco_p_mttrapd tcp 0 0 192.168.0.34:4500 192.168.0.34:32997 + ESTABLISHED 22948/nco_objserv tcp 0 0 192.168.0.34:4500 192.168.0.34:32996 + ESTABLISHED 22948/nco_objserv unix 2 [ ACC ] STREAM LISTENING 4500 1934/gpm + /dev/gpmctl

In reply to Re^2: Problem with Socket Programming Perl Script by ashok.g
in thread Problem with Socket Programming Perl Script by ashok.g

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.