Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IO::Socket and IO:Select problem

Posted on 1998-08-11
2
Medium Priority
?
411 Views
Last Modified: 2008-03-10
Hi!
I'm programming a chatserver in perl. Over the same socket different chatters are to receive the output.
Therefore I'm using IO::Socket and IO:Select. But until now I do only have a quite complicated way to send output to a certain chatter
...
my $listen = IO::Socket::INET->new(Proto => 'tcp',
                           LocalPort => 2323,
                           Listen => 1,
                           Reuse => 1) or die $!;
my $select = IO::Select->new($listen);
...
   for $socket ($select->handles) {
      if (($socket->fileno) == 5)   ### in this case only socket-connection
                                      ### with fileno = 5 should receive $outputstuff
           {$socket->send($outputstuff);}
}
...

Is there a command to send data directly to one certain socket-fileno without running a loop over all available socket-connections?
Thanx a lot!
0
Comment
Question by:kertis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 150 total points
ID: 1209202
Simple, brute force solution.  As you're opening sockets, assign a reference to the socket to a hash based on the fileno...

i.e.

my(%FileNos);
.

$FileNos{$socket->fileno} = \$socket;
..


Later, then, you can just do:

$FileNos{5}->send($outputstuff);

0
 

Author Comment

by:kertis
ID: 1209203
OK, that works just fine. If there's a way to access sockets by fileno directly please feel free to add a comment.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question