The commands to use sockets in perl are accept, bind, connect, getpeername, getsocketname, getsockopt, listen, recv, send, setsockopt, shutdown, socket and socketpair.

These calls are just perl versions of standard unix calls. So you can either read about them in the perl man pages (in perlfunc and in perlfaq9) or just read a book about socket or unix network programming. Or find a website that gives information about that.

You could also dissect some perl module like Net::FTP but I would advise against that, at least in the beginning.

To make a perl script a "port controller" for another program for which you don't have the source code, you could let that other program listen to a port opened by your perl script and let the script open the port to the outside world. That is, your script would work as a pipe/filter between the program and the outside world.

If you have the source code, it would be far easier to patch the program to listen to signals sent by the perl script.

Another way would be that your script just kills the program that listens on that port when it wants the port closed, and restarts it if it wants to open the port.


In reply to Re: Port control using perl? by jethro
in thread Port control using perl? by jkm199

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.