Hi,
I have a perl executable (kindof like an application) which is running on a remote machine... And people in that place only could control the exe ( like input data, accept choices etc. )
To do all that from my place, i've started to use sockets. Since I'm new to sockets and i've got to do the code in less than a week, i've not experimented with it much.
My client looks like this:
$sockclient = new IO::Socket::INET (PeerAddr => $remote_host, PeerPort => $remote_port, Proto => 'tcp', ); die "Socket could not be created. Reason: $!\n" unless $sockclient +;
And my server like this :
foreach my $hostvar (@remote_host) { $sockserver = new IO::Socket::INET (LocalHost => $hostvar, LocalPort => $remote_port, Proto => 'tcp', Listen => 5, Reuse => 1 + ) or warn "Socket could not be created in $hostvar. Reason: $!" unless +$sockserver; } while ($new_sock = $sockserver->accept()) { while (defined ($buf = <$new_sock>)) { # do something with $buf, and ask confirmation, input #etc. from + the client and again come back ... in a loop. } } close ($sockserver); }
Could anybody suggest a reliable approach to this so that :
1. My server is running infinitely,
2. My client is connected to the server, and sends info.
3. My server does something with the data and asks client for more input..
4. 2 and 3 continously until some pre-defined key is pressed.

Thanks...Rupz.

In reply to Sock-Server and Sock-Client by rupesh

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.