Hello, Thanks for all your help. I stripped out all the unnecessary code in Script #1. You should be able to execute the script now. I also sent another script, Script #2 that you can execute to send the Find min message to the Script #1. Try executing these and see if you can get Script #2 to send the message successfully. If it will not work, I will take your suggestion and add the forking to the script. The problem is that i am not sure where to actaully add it to Script #1. Could you guide me as where to add it? Again, Thanks so much Here are the scripts: Script #1: This is the script with all the oracle and all other unneccesary code striped out of it. I aded code that will emulate the send of the message bypassing the oracle.
#!/usr/bin/perl -w require 5.002; use strict; use IO::Socket; use IO::Select; our ($find_min_request_rec, $find_response_rec, $price_call_rec); our $read_set ; our $rh; our $ns; our $buf; our $iroam_req_type; # Create the receiving socket my $s = new IO::Socket::INET ( LocalHost => '172.17.8.201', LocalPort => '18490', Proto => 'tcp', Listen => 5, Reuse => 1, ); die "Could not create socket: $!\n" unless $s; $read_set = new IO::Select(); # create handle set $read_set->add($s);# add main socket to the set print "At Host/Port listening. Waiting to receive transactions..\n"; while (1) { # Continous Listening on Port # get a set of readable handles my ($rh_set) = IO::Select->select($read_set, undef, undef, 0); # take all readable handles in turn foreach $rh (@$rh_set) { print "Process each readable handle...\n"; if ($rh == $s) { print "Main socket/incoming connection..\n"; $ns = $rh->accept(); $read_set->add($ns); # otherwise it is an ordinary socket and # we should read and process the request }else{ print "An ordinary socket..\n"; print "Connected from: ", $rh->peerhost(); print " Port: ", $rh->peerport(), "\n"; $buf = <$rh>; $iroam_req_type = substr($buf,0,8); if($buf) { # return normal input and process $buf if ($iroam_req_type =~ /FindMin/){ $find_min_request_rec = $buf; }elsif ($iroam_req_type =~ /PriceCall/){ $price_call_rec = $buf; } $find_response_rec = 'GCD 0003002296392 ENGLISH YNNNNN00 +0024160000'; $rh->send($find_response_rec); }else { # the client has closed the socket $read_set->remove($rh); close($rh); } } } }
Script #2: You can use this script to acyually send the Findmin message to the port. Execute this one first to send the message to the port. This first one up above will be the one receiving the message.
#!/usr/bin/perl use strict; use IO::Socket; our $iroam_req = 'FindMin TLK 91271558098436895219S 95TestRSU3 +33333333 888888885555520070718103045'; our($sock); main_process(); sub main_process{ print "main process sub....\n"; open_socket(); print $sock $iroam_req; ####close($sock); ###sleep 5; ###open_socket(); ###print $sock $iroam_req; ###close($sock); ###sleep 5; } sub open_socket{ $sock = new IO::Socket::INET ( PeerHost=> '172.17.8.201', PeerPort => '18490', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; }

In reply to Re^4: Perl Sockets by crawfordr
in thread Perl Sockets by crawfordr

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.