Lincoln D. Stein
A text focusing on the methods and alternatives for designed TCP/IP-based client/server systems and advanced techniques for specialized applications with Perl. A guide examining a collection of the best third party modules in the Comprehensive Perl Archive Network. Topics covered: Perl function libraries and techniques that allow programs to interact with resources over a network. IO: Socket library ; Net: FTP library -- Telnet library -- SMTP library ; Chat problems ; Internet Message Access Protocol (IMAP) issues ; Markup-language parsing ; Internet Protocol (IP) broadcasting and multicasting.
Are there links, materials, or books about network programming with Perl that are relevant to 2010? I saw some books on programming the network with Perl are very old (about a decade) and the tutorials on the internet are also old and using old modules.
Could someone provide a good reference about programming sockets and network layer/application layer protocols with Perl that are updated to 2010?
Although Lincoln Stein's Network Programming with Perl is a bit old, the content is still mostly good. Network programming at that level hasn't changed that much in the last couple of decades. If you want to learn to play with sockets, that's the book to get to get you started.
However, Perl at the socket level does that same thing the C libraries do. There might be some nice interfaces around it, but look under the interface and you'll see the same things.
I need to move some data from one machine to another. Is it a good idea to write a client server app using sockets in Perl to do the transfer? Will I have problems if one side is written in Java?
I mean, should I be aware of any issues I might face when I try to attempt the above?
Short answer: Using a Perl program as the client or server is just fine. Your only problem might be your personal skill and experience level, but after you do it you know how to do it. :) Most of the problem is choosing how you need to do it, not the technology involved. Perl isn't going to be the problem, but it doesn't have an advantage over other languages either.
As some have already noted, the socket portion of the problem is going to be the same in most languages since almost everything uses the BSD stuff. Perl doesn't have any roadblocks or special gotchas for that. To move data around you create one side to listen on a socket and the other to open a connection and send the data. Easy peasy. You might want to check out Lincoln Stein's Network Programming with Perl for that bit. That can get you the low-level bits.
For higher-level networking, POE is very useful and easy to work with once you get started. It's a framework for dealing with event-driven programming and has many plugins to easily communicate between processes. You might spend a little time learning it, but it gives a lot back too.
If you aren't inventing your own protocol, there's most likely already a Perl module that can format and parse the messages.
If you just want to transfer data, there are several things you can do. The easiest in concept might be just to write lines to the socket and read them as lines from the other end. A bit more complicated than that is using something like Data::Dumper, YAML, or JSON to serialize data to text and send that. For more complex things, such as sharing Perl objects, you might want to use Storable. You freeze your objects, send them as data over the network, then thaw them on the other side.
If you want to implement your client and server in different languages you have a bit more work to figure out how they'll talk to each other. The socket stuff is mostly the same, but a Java server won't understand the output of Perl's Storable (it's possible, but you'll have to parse it yourself and that's no good :). If you do everything right, neither side should care what you used on the other side.
I have a script that runs on a server and I want it now to send messages to my PC. I want to send TCP or UDP messages to some port.
What is the best way to do this (a tutorial will be great)?
And is there some client program that I can run on my PC that will listen to a local port for the messages?
I want to listen on different sockets on a TCP/IP client written in Perl. I know I have to use select() but I don't know exactly how to implement it.
Can someone show me examples?
You might want to check out Network Programming with Perl. It's a bit dated, but the topic hasn't changed that much.