This is an interesting issue... I've written a small client program to connect to a certain port, send a query and receive back some information.
#!/usr/bin/perl
use strict;
use warnings;
# usage: ./ltsp_client.pl mac_address
use Carp;
use IO::Socket::INET;
die "Could not create socket: $!" unless
my $sock = IO::Socket::INET->new(
PeerAddr => 'xxxx.xxxx.com',
PeerPort => xxxx,
Proto => 'tcp',
Type => SOCK_STREAM,
Timeout => 10,
);
foreach my $cmd (@ARGV) {
print $sock "$cmd\n" or die $!;
}
print $sock "EOT\n" or die $!;
my @text = <$sock>;
close($sock) or die $!;
print @text;
This script runs fine when I ssh to the
LTSP server and run it from the command line. However, each LTSP terminal that will run this script takes its filesystem from the server, and the only writable directory is /tmp - the rest are read-only. When I try to run the script from the LTSP terminal's command line, I get the error "Could not create socket: Invalid argument at /usr/local/bin/ltsp_client.pl line 11."
Can anyone tell me why this is the case, and better yet how to resolve this issue? Thanks in advance!
Update: Resolved!! The issue lies somewhere in the hostname lookup. Changing the PeerAddr from using the name to using the IP resolved my issue. I still need to figure out why that's a problem, but at least now my project can progress. Thanks again to the responders, especially
Thelonius for reminding me to use the debugger.
---
It's all fine and dandy until someone has to look at the code.
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.