OK, I'm trying this IO::Socket stuff out for the firat time and I'm not having much luck. I've tried a million things. The code right out of Camel v2 doesn't even work for me. No errors, just refused conections. Is it me? any and all comments welcomed and appreciated.

the server:

use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new( LoclaPort => 1776, Type => SOCK_STREAM, Reuse => 1, Listen => 10 ) or die "Big Problem with the Server, Man : $!\n\n"; while ( my $client = $socket->accept() ) { { my $child; # perform the fork or exit die "Can't fork: $!" unless defined ($child = fork()); if ($child == 0) { #i'm the child! #close the child's listen socket, we dont need it. $socket->close; #call the main child rountine print $client 'Hello, down there!!', "\n\n"; #if the child returns, then just exit; exit 0; } else { #i'm the parent! #who connected? warn "Connecton recieved ... ",$client->peerhost,"\n"; #close the connection, the parent has already passed # it off to a child. $client->close(); } #go back and listen for the next connection! } } close($socket);
"A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche
the client:
use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '1776', Proto => "tcp", Type => SOCK_STREAM) or die "Big Problem, Man : $!\n\n"; my $response = <$socket>; print $response, "\n\n" if $response; close($socket);
I've looked in the Camel; I've seen MP3 server with IO::Socket (stealum much code there), Where can I find resources about Socket, IO::Socket, IO::Socket::INET, and forking server but nothing going from any of them...

In reply to IO::Socket::INET server(?) by jptxs

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.