Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Add HTTP Post For Socket Connection

by flexvault (Parson)
on Nov 07, 2012 at 21:11 UTC ( #1002747=note: print w/ replies, xml ) Need Help??


in reply to Add HTTP Post For Socket Connection

Well done Perlbotics,

Thanks to a suggestion from Perlbotics who said "Re Re: Add HTTP Post For Socket Connection Hi, simple trick - unless you were joking ;-) (Right-?)Click your browsers "Show Sourcecoude" or "View Page Source" option and scroll to the posting. Most of the time, the copy/pasted stuff is readable there. Regards, PB" and it worked!

#!/usr/bin/perl use strict; use IO::Socket; use DBI; use DBD::Oracle; our (@command, $command); our ($socket_success_fl); our $svcpk; my $cable_command; ##$cable_command = ' ##<Transaction id = "12345" wait="1" priority="1"> ##<AddUpdateLocation> ##<LocationId> 8002721493 </LocationId> ##<HeadendCode> 01 </HeadendCode> ##<Address1> 19 Bow Circle </Address1> ##<Address2> Bow Circle Business Ctr Unit 402 </Address2> ##<City> Hilton Head Island</City> ##<State> SC </State> ##<Zip> 29926 </Zip> ##</AddUpdateLocation> ##</Transaction>'; ####$cable_command = $ARGV[0] #### or die "Could not find an argument \n"; print "$cable_command\n"; $socket_success_fl = 'N'; socket_connect(); if ($socket_success_fl =~ /Y/){ process_command(); socket_close(); }elsif ($socket_success_fl =~ /N/){ print "Unable to connect to socket!!....\n"; } sub socket_connect { socket (SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die $! +; my $dest = sockaddr_in (22928, inet_aton('172.17.15.102')); connect (SH, $dest) || die $!; $socket_success_fl = 'Y'; print "Connected to socket\n"; } sub process_command { my $v_param; my $buffer; $v_param = $cable_command; @command = split(/&/,$v_param); foreach $command (@command) { print "$command\n"; if ($command =~ /SVCPK=/ ) { $svcpk = substr($command,6,10); print "svcpk = ", $svcpk, " \n"; } else { print "About to send command\n"; send (SH, "$command\r", 0); print "sent command\n"; print "about to read response buffer\n"; sysread (SH, $buffer, 1000); print "read response buffer\n"; print "response = ", $buffer, " \n"; } } } sub socket_close{ close(SH); print "Socket closed \n";

++ to Perlbotics, who sent the above private message to show an old dog a new trick! Well Done!

"Well done is better than well said." - Benjamin Franklin


Comment on Re: Add HTTP Post For Socket Connection
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002747]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-09-18 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (125 votes), past polls