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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.