Dereferencing Objects

$

$_

Hello,

Would someone please help me with this 'dereferencing' problem?
I've searched this group for solutions posted previously and
did find three threads that kept me busy trying differnt things;
but this unfortunatly didnt solve my problem. This seems like
it will require dereferencing an object that references another
object in another package.

Please reply if you have any helpful information that may solve
this problem.

Here is the example code (the screen output is in comments):

#!
use strict;
use warnings;
use IO::Socket;
use IO::LineBufferedSet;
use Fcntl qw:)DEFAULT :flock);

#Declarations#
my ($listen_socket, $session_set,);

#Main#
$listen_socket = IO::Socket::INET->new(LocalPort => 11111,
Timeout => 32,
Listen => 64,
Reuse => 1,
Proto => 'tcp',);
if ($listen_socket) {
$session_set = IO::LineBufferedSet->new($listen_socket);
}else{
die "\aCan't create a listening socket\n$@";
}

#Mainloop#
while (1) {
my @ready = $session_set->wait;

my @sessions = $session_set->sessions();
print "$sessions[0]\n";

#This is the output from the above command:
#IO::LineBufferedSessionData=HASH(0x1c6b06c)
}
 
A

Ala Qumsieh

$_@_.%_ said:
#!
use strict;
use warnings;
use IO::Socket;
use IO::LineBufferedSet;
use Fcntl qw:)DEFAULT :flock);

#Declarations#
my ($listen_socket, $session_set,);

#Main#
$listen_socket = IO::Socket::INET->new(LocalPort => 11111,
Timeout => 32,
Listen => 64,
Reuse => 1,
Proto => 'tcp',);
if ($listen_socket) {
$session_set = IO::LineBufferedSet->new($listen_socket);
}else{
die "\aCan't create a listening socket\n$@";
}

#Mainloop#
while (1) {
my @ready = $session_set->wait;

my @sessions = $session_set->sessions();
print "$sessions[0]\n";

#This is the output from the above command:
#IO::LineBufferedSessionData=HASH(0x1c6b06c)

Correct. That's just what the docs for IO::LineBufferedSet says:

<quote>
=item @sessions = $set->sessions

The sessions() method returns a list of IO::LineBufferedSessionData
objects, each one corresponding to a handle either added manually with
add(), or added automatically by wait().
</quote>

So your @sessions array will hold a list of IO::LineBufferedSessionData
objects (which are just blessed hashes). Check the docs of
IO::LineBufferedSessionData for how to extract information from it.

--Ala
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

polling TCP server on Win32 (with Tk) 1
problem with IO:Socket 2
Can't connect to 'localhost' in IO::Socket 15
UDP receive 2
I Broke a scalar 5
while (1) in server 1
help with IO::Socket:INET 4
thread 2

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,204
Latest member
LaverneRua

Latest Threads

Top