Gossamer Forum
Home : General : Perl Programming :

Socket PM

Quote Reply
Socket PM
Hi

Can you show me how to build a simple socket connection?

For example

- connect to a URL via socket,

- then print results from the remote server to my HTML output.

Thanks!!!!!!!

Roby
Quote Reply
Re: [robyone] Socket PM In reply to
Could I ask for some more details, such as why you need a socket?

What are you trying to achieve (just to help me assess if there's a better way)?

Last edited by:

Paul: Jan 13, 2003, 1:38 AM
Quote Reply
Re: [robyone] Socket PM In reply to
Read the perlipc manpage.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Paul] Socket PM In reply to
Paul

it is for my payment gateway requirements. It requires a socket connection but i need a simple, really simple connection to https://servername on port 443 via socket. Then get the string back to and read it for the response to the browser. Any experience?

Thanks.
Quote Reply
Re: [robyone] Socket PM In reply to
You can fetch a webpage with LWP::UserAgent. I think if you are connecting to a secure server you will need Crypt::SSLeay - but not sure on that.

Is this for paypal?
Quote Reply
Re: [Paul] Socket PM In reply to
That's for authorizenet

I tried it and I got a HTTP::Response=HASH(0x82ba980)

:((

Ideas?
Quote Reply
Re: [robyone] Socket PM In reply to
Thats the response object - you need something like....

Code:
my $response = $lwp->request( ... );

if ($response->is_success) {
my $data = $response->content;
...
}
else {
die $response->message . ' (' . $response->code . ')';
}
Quote Reply
Re: [Paul] Socket PM In reply to
I got this error

Protocol scheme 'https' is not supported
Quote Reply
Re: [robyone] Socket PM In reply to
This normally happens if LWP needs upgrading or if your server doesn't have all the necessary SSL libs installed.

I remember getting the same error for http:// and upgrading LWP seemed to solve it.
Quote Reply
Re: [Paul] Socket PM In reply to
Don't you know how to do it via socket /io::socket?
Quote Reply
Re: [robyone] Socket PM In reply to
I got it up but I'm getting an error form the remote server telling that connection method is not supported.
Quote Reply
Re: [robyone] Socket PM In reply to
 
Code:
my $sock = IO::Socket::INET->new(
PeerAddr => 'www.domain.con',
PeerPort => 'https(443)',
Proto => 'tcp'
);

What code did you try?
Quote Reply
Re: [Paul] Socket PM In reply to
use IO::Socket;

$sock = IO::Socket::INET->new(

PeerAddr => "certification.authorize.net", #test server

PeerPort => "https(443)", #used 443 or https(443)

Proto => 'tcp',

Timeout => "20",

)

or die print "cannot connect to daytime port at localhost";

print $sock "GET /gateway/transact.dll HTTP/1.0\n\n";

while (<$sock>) {

print;

}

$sock->close();

--------------------

I can get anything from the server ...

Quote Reply
Re: [robyone] Socket PM In reply to
In the IO::Socket code it prints nothing with $sock
Quote Reply
Re: [robyone] Socket PM In reply to
Do authorizenet not have any documentation or code samples?
Quote Reply
Re: [Paul] Socket PM In reply to
http://www.authorizenet.com/support/AIM_guide.pdf
Quote Reply
Re: [Paul] Socket PM In reply to
The code you have should work AFAIK so you may be best contacting authorizenet to see if they can shed light as to why you are receiving nothing back.
Quote Reply
Re: [robyone] Socket PM In reply to
Quote:
Protocol scheme 'https' is not supported

You need to install the Net::SSL module:

http://cpan.gossamer-threads.com/...t-SSLeay-0.45.tar.gz

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Socket PM In reply to
And then reinstall LWP if I remember correctly.

- wil