#What I am ultimately trying to accomplish:
My ultimate goal is to forward everything that a raw socket picks up at 0.0.0.0 over an XMPP chat line get another computer to receive the data and pass it on to its 0.0.0.0 address via another raw socket. I almost had it in python using an IRC, but found that IRCs do not like long messages or many short ones. XMPP servers seem to be less restrictive so I was hoping the system would work with one of those. I decided to switch from Python to Perl after evaluating all the socket management and XMPP client modules for a number of scripting languages. After attempting this in a number of scripting languages, I have learned to come pretty close to my final goal by starting with an XMPP (or IRC) echo bot and a socket server that prints data to the screen and/or sends it back to the source. In the past I used TCP, but I am switching to raw sockets for a number of reasons that are not important for this particular question.

#What I would like to be able to do first:
For the time being, I have been trying to learn to set up a raw socket, bind it to address 0.0.0.0, and have it print everything it receives in an event driven manner. I assumed this would mean using IO::Async or AnyEvent. I found that AnyEvent does not like raw sockets because they are "not streams" or something, so I was trying to use IO:Async. However, I am not very familiar with Perl, and I honestly have just been trying to hash together example codes so I can study something. I cannot imagine this is very hard to do, but for some reason I cannot figure out how to do it.

#What am asking of anyone who would be willing to help:
I would really appreciate some example codes that use raw sockets. Something that prints the raw data to the screen and/or echos it back to the sender would be great. From there, I need to learn how to set up an event driven echo bot for XMPP in Perl. Once I have those, I already know how I want to combine them into something that transmits data over a chatline because I have done similar things in other scripting languages.

Thanks


In reply to Printing data from a raw socket to the screen and/or echoing it back via event driven means by Feynman

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.