in reply to Very basic socket question

Depending on what it is that you want to do, you might consider using a higher-level library than just basic sockets. For instance, a while back I needed to put together a client/server networking module for getting backups moved from one system to another across a network. There are a number of ways I could have done it, but I ended up combining HTTP::Daemon on the one end with system('wget', @args) on the other. In retrospect, I could just as easily have used WWW::Mechanize instead of wget and/or Net::Server in lieu of HTTP::Daemon. For that matter, the one system has Apache running anyhow, so I could have used WWW::Mechanize on the one end and plain old CGI on the other. If what you're doing could use features you don't feel like implementing, such as the ability for more than one client to connect at a time, going with one of these routes is worthwhile. After all, who wants to write forking code when you don't have to?

On the other hand, if your goal is learning about networking, then writing a basic client/server socket setup is quite worthwhile. My first experiment in this was a Hello, World server -- the client would connect and say "Hello, Server World", and the server answered back, "Hello, Client World". The downside of this kind of lowlevel approach is that the server for my Hello, World thing is over forty lines, and all it does is listen for one client connection at a time, check if they say a certain thing, say a certain thing back, log it, and close the socket. That's not very much to do in forty lines of Perl.


"In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

Replies are listed 'Best First'.
Re^2: Very basic socket question
by blazar (Canon) on Jun 29, 2005 at 15:00 UTC
    Thank you for the extensive answer. The goal is not much more complex than the explicit description given in the original post. Of course I'm trying to make this into a chance for learning about networking.

    Certainly I'm aware of the LWP family of modules, and I've heard but not really used (yet) WWW::Mechanize - in any case I'm not about to reimplement them!!

      Hi,

      I recommend you this book, is not about Perl, it's C, but anyway the concepts can be ported, and gives you an idea on low level, so you can understand well the IO::Socket, and network programming in general.

      Also take a look at POE, you can do really nice things with it.

      Regards,

      |fire| at irc