Something like that would be ideal. I thought IO::Async or AnyEvent would make for a nice substitute for the fictitious My::MagicEventBasedModule. As you can see in the pseudocode, I associated a subroutine with a point at which $my_event_loop_handler_thing detects the filehandler to have data that could be read. In my pseudocode, the subroutine is passed the data along with the source address and port that sent it. That would be nice, but all I really need is the data. The raw IP packet would contain all the information I would need. Actually I would just encode it in hex and pass it over XMPP to the other computer, which would decode it and feed it to its raw socket at 0.0.0.0. Then the process would start again as the other computer replies. For now, I just need to know how to use an event based module to print raw data from a raw socket to the screen every time data is sent to the socket. The reason I want it to be event based is so I am not explicitly assigning threads and/or processes to constantly check the socket and the XMPP client for new data and messages respectively.use IO::Socket::INET; my $server = new IO::Socket::INET(LocalAddr => '0.0.0.0', Proto => 'ra +w'); use My::MagicEventBasedModule; my $my_event_loop_handler_thing = new My::MagicEventBasedModule ( file_handler => $server, when_there_is_data_to_be_read => sub{ my ($data, $source_address, $source_port) = @_; print $data; $server->write("You've got data!"); } ); #maybe you have to "run" it like a thread in Python: $my_event_loop_handler_thing->run();
In reply to Re^2: Printing data from a raw socket to the screen and/or echoing it back via event driven means
by Feynman
in thread Printing data from a raw socket to the screen and/or echoing it back via event driven means
by Feynman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |