Greetings,

I am trying to use Perl to communicate over Ethernet sockets using quad port cards. I have several problems. Here is what I am doing in what I hope is a logical sequence.

FINAL GOAL: Use Perl to communicate over UDP or TCP/IP to Linux boxes. Each box will have one or more Adaptec ANA-6944A/TX quad port NIC cards. Almost all box to box communication will be through the quad port NIC cards, but some may be through the port on the motherboard.

INITIAL GOAL: Set up one box with quad port cards and use Perl to communicate from one port to another. Program should not get hung if there is a communication failure.

SO FAR:
1) Cards physically installed in box.
2) Ubuntu 6.10 Desktop installed from CD
3) Updates installed over internet
4) Various utility packages installed from internet using “apt-get install”.
5) Addresses manually assigned to ports via SYSTEM -> ADMINISTRATION -> NETWORKING.
6) Ports activated via a root command line. Sample: ifup eth8.

NOW: focus on only eth8 & eth10 (picked at random)

eth8 was assigned 192.168.21.28
eth10 was assigned 192.168.22.30

I expect routing problems, but I also expect that with a good route set up I should be ok. At this point I charge forward to see how far I can go. My program is:

====================================================================== #!/usr/bin/perl # FILE: try_socket_perl_monks.pl # use warnings; use strict; print "PROGRAM: try_socket_perl_monks.pl \$ARGV[0]=$ARGV[0]\n"; my $MySocket; # socket my $t; # time use IO::Socket; if ($ARGV[0] eq "A") { $MySocket=new IO::Socket::INET->new(Proto => 'udp', PeerAddr=> '192.168.22.30', PeerPort=>8005, LocalAddr=> '192.168.21.28', LocalPort=>8006); print "Configuration A, \$MySocket=$MySocket\n"; } elsif($ARGV[0] eq "B") { my $MySocket=new IO::Socket::INET->new(Proto => 'udp', PeerAddr=> '192.168.21.28', PeerPort=>8006, LocalAddr=> '192.168.22.30', LocalPort=>8005); print "Configuration B, \$MySocket=$MySocket \n"; } elsif($ARGV[0] eq "C") { my $MySocket=new IO::Socket::INET->new(Proto => 'udp', PeerAddr=> '192.168.20.223', PeerPort=>8006, LocalAddr=> '192.168.21.28', LocalPort=>8005); print "Configuration C, \$MySocket=$MySocket \n"; } else { print "Passed argument error \n"; } if (defined($MySocket)) { print "\$MySocket = $MySocket\n"; } else { print "\$MySocket not defined\n"; } my $msg = "This is a test message 123456789012345678901234567890123456 +78901234567890\n"; $MySocket->send($msg); $MySocket->send($msg); $MySocket->send($msg); $MySocket->send($msg); print "After the sending of the message\n"; my $text; my $more = 1; my $retries = 0; do { eval { local $SIG{ALRM} = sub{++$retries and die "timeout\n" }; alarm(3); $retries++; print "above the recv, \$retries=$retries\n"; $MySocket->recv($text, 128) or die "recv failed: $!"; alarm(0); print "\$retries=$retries, length(\$text)=" . length($text) . + "\n"; }; print "retrying \$retries=$retries\n"; } while $retries < 4; print "END OF PROGRAM\n\n";

My first run should be from one port on the quad card to another port on the quad card. The results are:

PROGRAM: try_socket_perl_monks.pl $ARGV[0]=A Configuration A, $MySocket=IO::Socket::INET=GLOB(0x818416c) $MySocket = IO::Socket::INET=GLOB(0x818416c) After the sending of the message above the recv, $retries=1 retrying $retries=2 above the recv, $retries=3 retrying $retries=4 END OF PROGRAM

This did not get stuck (GOOD!!!) but the hub lights did not blink (bad but not totally unexpected).

My second run should be using the same ports on the quad card as my first run, but the ports are reversed. The results are:

PROGRAM: try_socket_perl_monks.pl $ARGV[0]=B Configuration B, $MySocket=IO::Socket::INET=GLOB(0x81842e4) $MySocket not defined Can't call method "send" on an undefined value at ./try_socket_perl_mo +nks.pl line 59

Here is where everything falls apart far worse than I expected. I see no reason why the first run and the second run didn’t have the exact same degree of success or failure.

My third run was to another machine. The other machine did not have code to receive and/or reply to this message, but the other machine was outside this linux box and therefore I would expect routing issues to be resolved. The results of my third run are:

PROGRAM: try_socket_perl_monks.pl $ARGV[0]=C Configuration C, $MySocket=IO::Socket::INET=GLOB(0x81842e4) $MySocket not defined Can't call method "send" on an undefined value at ./try_socket_perl_mo +nks.pl line 59

Once again, failure.

I went through many iterations of “route add” and “ip route add” and before my first reset I was able to get ping to send ARP requests out of the box via “ping –I eth8 192.168.22.30” type command lines. After the reset I don’t seem to be able to get out of the box on the quad cards.

My various route attempts created a big mess with no visible improvement in my situation. Thus, I think it is counter productive to list them here.

At this point I am hitting a brick wall on several issues:
1) Why do runs that seem like they should be the same produce different results?
2) Can I go from one port on a quad card to another port on a quad card? I am willing to do “crazy things” like assign a different network number (192.168.21.x, 192.168.22.x, etc.) to each port if necessary.
3) How do I set up whatever is needed to use Perl to go from a quad port on one Linux box to a quad port on another Linux box?
4) Why, when I was getting ARP requests out of the box was I not getting any ARP replies (I used Ethereal on both ends of the connection)

Thank you,
Bruce

Edit: g0n - code tags and formatting


In reply to socket communication problems by Bruce32903

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.