CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Windows multiplexing

 



grlemn
Novice

Feb 10, 2010, 2:50 AM

Post #1 of 3 (1117 views)
Windows multiplexing Can't Post

Hi guys i am trying to use multiplexing on Windows 7 environment but as you know multiplexing can only work with sockets.The question is how can i make multiplexing
script work with STDIN and STDOUT? Can you help me with sample code? Thanks in advance.


FishMonger
Veteran / Moderator

Feb 10, 2010, 5:17 AM

Post #2 of 3 (1113 views)
Re: [grlemn] Windows multiplexing [In reply to] Can't Post

IO::Tee - Multiplex output to multiple output handles
http://search.cpan.org/~kenshan/IO-Tee-0.64/Tee.pm

PerlIO::tee - Multiplex output layer
http://search.cpan.org/~gfuji/PerlIO-Util-0.71/lib/PerlIO/tee.pm

IO::Multiplex - Manage IO on many file handles
http://search.cpan.org/~bbb/IO-Multiplex-1.10/lib/IO/Multiplex.pm


grlemn
Novice

Feb 12, 2010, 9:50 AM

Post #3 of 3 (1054 views)
Re: [FishMonger] Windows multiplexing [In reply to] Can't Post

That's my code i have problem:

<code>

use IO::Socket::INET;

use IO::Select;

syswrite(STDOUT,"----- Server Program -----\n");


$socket=new IO::Socket::INET->new(LocalPort=>1234,Proto=>'udp') or die "socket() error: $!";

$select=IO::Select->new($socket);

LOOP:

while(1)

{

if(@readers=$select->can_read(0.1))

{
$socket->recv($msg_in,128);

syswrite(STDOUT,"\nPeer>$msg_in");


}
else
{
syswrite(STDOUT,"Enter message to send to server : ");

sysread(STDIN,$msg_out,100);

send($socket,$msg_out,0,'localhost');

goto LOOP;
}

}

exit 1;

</code>

==============================

<code>

use IO::Socket::INET;

use IO::Select;


syswrite(STDOUT,"----- Client Program -----\n");


$socket=new IO::Socket::INET->new(PeerPort=>1234,Proto=>'udp',PeerAddr=>'localhost') or die "socket() error: $!";

$select=IO::Select->new($socket);



LOOP:

while(1)

{

if(@readers=$select->can_read(0.1))

{
$socket->recv($msg_in,128);

syswrite(STDOUT,"\nPeer>$msg_in");


}
else
{
syswrite(STDOUT,"Enter message to send to server : ");

sysread(STDIN,$msg_out,100);

$socket->send($msg_out);

goto LOOP;
}

}

exit 1;

</code>

But when i send messages from client the server doesn't print the data on screen but in order to print it i have to change line(newline).It acts like it buffers the data.I would appreciate any ideas.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives