Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

E-Machines T2862 won't print to a socket.

by Bro. Doug (Monk)
on Oct 31, 2006 at 02:29 UTC ( #581407=perlquestion: print w/replies, xml ) Need Help??

Bro. Doug has asked for the wisdom of the Perl Monks concerning the following question:

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 = '' ; 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.
Bro. Doug :wq

Replies are listed 'Best First'.
Re: E-Machines T2862 won't print to a socket.
by quester (Vicar) on Oct 31, 2006 at 05:31 UTC
    This is really a job for a protocol analyzer running on either the server at $PM_ADDR or on the client, or, preferably, both. If you don't already have ethereal (recently renamed wireshark) or tethereal (tshark) on your system, you can download it for Windows or *nix from It should look something like this with tethereal/tshark, or prettier and with tons more detail on ethereal/wireshark:
    # tethereal -i eth0 Capturing on eth0 0.000000 client_ip -> server_ip TCP 50007 > www [SYN] Seq=0 Len=0 MS +S=1460 TSV=333203 TSER=0 WS=7 0.004236 server_ip -> client_ip TCP www > 50007 [SYN, ACK] Seq=0 Ack +=1 Win=8192 Len=0 MSS=1460 WS=0 TSV=125990 TSER=333203 0.004357 client_ip -> server_ip TCP 50007 > www [ACK] Seq=1 Ack=1 Wi +n=5888 Len=0 TSV=333204 TSER=125990 0.006432 client_ip -> server_ip HTTP Continuation or non-HTTP traffi +c 0.009844 client_ip -> server_ip TCP 50007 > www [FIN, ACK] Seq=11 Ac +k=1 Win=5888 Len=0 TSV=333205 TSER=125990 0.014528 server_ip -> client_ip TCP www > 50007 [ACK] Seq=1 Ack=12 W +in=8192 Len=0 TSV=125990 TSER=333204 0.015166 server_ip -> client_ip TCP www > 50007 [FIN, ACK] Seq=1 Ack +=12 Win=8192 Len=0 TSV=125990 TSER=333204 0.015230 client_ip -> server_ip TCP 50007 > www [ACK] Seq=12 Ack=2 W +in=5888 Len=0 TSV=333207 TSER=125990
    By comparing the output on a good machine and a bad one you can see exactly which packets are missing. By the way, if these are Windows machines, there is a possibility that the Windows Firewall configuration is your problem.
Re: E-Machines T2862 won't print to a socket.
by jbert (Priest) on Oct 31, 2006 at 10:42 UTC
    It seems likely to me that there is some program or service running as part of the shipped bundle for those machines. This is assuming that these machines have generally working network connections.

    Since your problem is network related, look for firewall software on those machines which is a different version (or differently configured) to your working machines.

    Some firewalls block outbound connections from unauthorised programs. You may need to add your perl.exe to the list of programs permitted to do this.

Re: E-Machines T2862 won't print to a socket.
by gellyfish (Monsignor) on Oct 31, 2006 at 08:59 UTC

    What happens when you try to connect to the same host and port using telnet from the command line on one of the machines in question?

    I'd guess the same thing. Which would suggest that you have a question about the configuration of the machines rather than about Perl. I would start looking at firewall software running on the machine.


Re: E-Machines T2862 won't print to a socket.
by greatshots (Pilgrim) on Oct 31, 2006 at 04:12 UTC
    did you trace the debugging output ?
Re: E-Machines T2862 won't print to a socket.
by derby (Abbot) on Oct 31, 2006 at 12:47 UTC

    getprotobyname (missing /etc/protocols?) and socket (most likely permission problems) can fail. What happens when you single step through the debugger?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://581407]
Approved by ikegami
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2023-06-09 04:41 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (35 votes). Check out past polls.