I'm trying to learn some basic network communications using the IO module. After
reading the man pages for
IO::Socket and
IO::Select I wrote the following
test script:
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use IO::Select;
my $s = IO::Select->new();
$s->add(\*STDIN);
my $foo;
my $msg;
$s->can_read();
foreach $foo ( $s->can_read() ){
$foo->recv($msg, 1024, 0);
print "$msg\n";
}
To me, this looks like it should work fine, but instead of running smoothly it
produces this error message:
Can't locate object method "recv" via package "IO::Handle" (perhaps you forgot
to load "IO::Handle"?)
Now, I didn't load IO::Handle, because I didn't need any of the functions from
it directly. I realize that IO::Socket inherits from IO::Handle, but shouldn't that
just take care of itself behind the scenes?
-Ben Jacobs (dooberwah)
http://dooberwah.perlmonk.org
"one thing i can tell you is you got to be free"
Edit: Added <code> tags. larsen
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.