Hi I wrote a socket server and client and tested on local host on my home system and I was able to communicate with multiple PC @ home. Now I moved the socket server to the web server and tried to test the client connection on my terminal. but every time i get a connection time out error message. I am posting the server code and client code here, can anyone help to find , what is going wrong....

Server

#!/usr/bin/perl use strict; use IO::Socket; use POSIX 'WNOHANG'; use constant PORT => 12000; my $quit = 0; $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG)>0) { } }; my $lisen_socket = IO::Socket::INET->new( LocalPort => PORT, Proto => 'tcp', Listen => 1, Reuse => 1 ); die "cant create a soocket \n" unless $lisen_socket; warn "server ready.. waiting for connection in port : 12000......\n"; while (!$quit) { my $connection; next unless $connection = $lisen_socket->accept; defined(my $child = fork()) or die "cannot fork : $!\n"; if($child == 0) { print "Inside child\n"; $lisen_socket->close(); &interact($connection); exit 0; print "exiting from child\n"; } $connection->close(); } sub interact { my $data; my $count = 0; my $sock = shift; #STDIN->fdopen($sock,"<") or die "cannot reopen STDIN : $!\n"; #STDOUT->fdopen($sock,">") or die "cannot reopen STDOUT : $!\n"; #STDERR->fdopen($sock,">") or die "cannot reopen STDERR : $!\n"; $| =1; while(defined $sock) { print $count; $data = <$sock>; if($data ne "") { print "Server : $data\n"; print $sock "type next line\n"; $count++; } } }

Client

#!/usr/bin/perl use strict; use IO::Socket::INET; $| =1; my $socket = IO::Socket::INET->new( PeerHost =>'208.91.198.132', PeerPort =>'12000', Proto => 'tcp', ) or die "cannot create a socket $@\n"; print "TCP Connection Creatred Sucessfully\n";

In reply to Why socket not responding in webserver by romy_mathew

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.