in reply to Port control using perl?

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.

Replies are listed 'Best First'.
Re^2: Port control using perl?
by jkm199 (Initiate) on Jul 30, 2008 at 02:14 UTC
    thank you very much :) thats exactly what i needed.
    Failure isn't about falling. It's remaining where you have fallen.