Esteemed monks,
I have a problem which has cost me a great deal of time and money. Five of forty-five PC's on a network won't print to a socket. The other forty handle this simple task just fine.
As it turns out, the five PC's are all the same model: Emachines T2862. When running a command like the one below it will hang forever.
print PM_SCK $out ;
Here's a working mockup of the socket connection.
#! /usr/bin/perl -wT
use strict ;
use warnings ;
use diagnostics ;
use Socket ;
use IO::Select ;
my @pm_send = () ;
# These should be altered by a config file, but for now
# I've given the addies for the monastery
my $PM_ADDR = '209.197.123.153' ;
my $PM_PORT = 80 ;
# Start the connection to the socket
my $proto = getprotobyname( 'tcp' ) ;
socket( PM_SCK, AF_INET, SOCK_STREAM, $proto ) ;
my $pm_in = sockaddr_in( $PM_PORT, inet_aton( $PM_ADDR ) ) ;
connect( PM_SCK, $pm_in) || warn "Can't create pm_sck: $!" ;
# set up autoflush
select( PM_SCK ) ; $| = 1 ; select ( STDOUT ) ;
# set up an IO::Select for polling PM_SCK
my $sck_poller = new IO::Select ;
$sck_poller->add( \*PM_SCK ) ;
# now, after some tedium related to the application,
# I do something that looks like:
push @pm_send, "Some data" ;
# and then, in a main loop, I:
sck_poll() ;
sub sck_poll {
if ( scalar @pm_send ) {
my @writeable = $sck_poller->can_write(0) ;
if( scalar @writeable ){
my $out = shift(@pm_send) . chr(1) ;
#this is the part that hangs forever.
print PM_SCK $out ;
print "You did it! \n" ;
}
}
}
The above (readmore enclosed) code runs on my Mac, and is culled from the application. It will probably run for you, too. But maybe someone has a T2862 with ActiveState Perl... does it run for you?
Peace, monks.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|