[Chicago-talk] Reading from a socket
lembark at wrkhors.com
Wed Feb 18 10:47:45 CST 2004
-- Jay Strauss <me at heyjay.com>
> Hi, I'm wondering if the is an easier (better) way to read a socket. I'm
> doing (roughly) like below. I noticed in POE you can just give it a
> message terminator, and if automatically reads it correctly. Is there a
> way to do this with IO::Socket::INET or maybe with sysread?
Once you're into sockets it's sysread time. You're
dealing with a simple file descriptor at that point.
If you consider it a useful exercise, write your own
sendbuf/recvbuf wrappers or pick any of Net::Blah
items that wrap the sockets for you. If you check
CPAN there are a few socket-wrapper classes that deal
with the read/write/error cycle in different ways.
Taking the time to write effecient wrappers once was
useful for me. It gave me a better feeling for what
might be going wrong inside of other modules. Dealing
with out-of-band data looks a bit flakey until you get
a feel for it.
Lincon's Network Prog. w/ Perl book also describes
the socket-wrapper classes with examples. You might
just want to eyeball that and pick the one that looks
useful to you.
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk