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

In reply to Re: Very basic socket question by jonadab
in thread Very basic socket question by blazar

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.