xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I want to msn my buddy under windows command prompt by MSN module. Below is part of my script.
my $run = 1; while( $run ) { $msn->do_one_loop(); } # do_one_loop is in MSN.pm sub do_one_loop { my $self = shift; # return immediately if we are not connected return if( !$self->{Connected} ); $self->{Notification}->ping( ); foreach my $convo (values %{$self->getConvoList()}) { $convo->p2pSendOne() if $convo->p2pWaiting; } my @ready = $self->{Select}->can_read(.1); foreach my $fh ( @ready ) { # get the filenumber for this filehandle my $fn = $fh->fileno; # get the object assocatied with this filenumber my $connection = $self->{Connections}->{$fn}; # DO WE NEED THIS CODE? if the connection is really dead, will + it even be showing up in the list of filehandles that can be read fr +om?? # if the connection is dead, remove it from the select, delete + it from the Connections list and output a warn if( !$connection->{Socket}->connected() ) { $self->{Select}->remove( $fn ); delete( $self->{Connections}->{fn} ); warn "Killing dead socket"; next; } sysread( $fh, $connection->{buf}, 2048, length( $connection->{ +buf} || '' ) ); while( $connection->{buf} =~ s/^(.*?\n)// ) { $connection->{line}= $1; my $incomingdata = $connection->{line}; $incomingdata =~ s/[\r\n]//g; print( "($fn $connection->{Type}) RX: $incomingdata\n" ) i +f( $self->{ShowRX} ); my $result = $connection->dispatch( $incomingdata ); last if( $result && $result eq "wait" ); } } }
The scirpt can connect to server successfully. But I can't input any command to CLI window(no operate,no echo). In fact, The command I input echo to CLI until I quit the script. I suspect that it related to Windows, but I can't be sure.
I hope I describe my question clearly enough. Thanks in advance!

I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: Can't use MSN
by ikegami (Patriarch) on Apr 28, 2007 at 02:50 UTC

    But I can't input any command to CLI window(no operate,no echo).

    I don't see any code that reads from STDIN or the terminal.

    if the connection is really dead, will it even be showing up in the list of filehandles that can be read from??

    Yes. select returns closed file handles as "Readable" so you can do some error handling and/or some cleanup.

    A reply falls below the community's threshold of quality. You may see it by logging in.