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. | [reply] |
| [reply] |
| [reply] |
| [reply] |
I would practice with Net::FTPServer for a while, then move up to Net::Server. That will give you a foundation that will get you ready to handle sockets. If you encounter any problems, post your questions. There are a lot of monks here that can help you with that. Probably the best thing to do right now is to try your hand at writing some code for your ftp client and go from there. Good luck and have fun...
| [reply] |