Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Strange HTTP Socket connexion problem

Reply
Thread Tools

Strange HTTP Socket connexion problem

 
 
axel@white-eagle.invalid.uk
Guest
Posts: n/a
 
      10-16-2005
I'm having a strange problem trying to connect to a specific site
with an HTTP request. Originally I was trying to send a SOAP request,
but have whittled the script down to the most basic HTTP request
possible:

--- start
#!/usr/bin/perl

use strict;
use warnings;
use Socket;

my $header = <<EOM;
GET / HTTP/1.1
Host: www.webservicex.net

EOM

socket (CLIENT, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
or die "socket: $!\n";
bind (CLIENT, sockaddr_in(0, INADDR_ANY))
or die "bind: $!\n";

my $host = 'www.webservicex.net';
my $rport = 80;
my $ip_addr = inet_aton($host)
or die "inet_aton: $!\n";
my $rsockaddr = sockaddr_in($rport, $ip_addr);
connect(CLIENT, $rsockaddr)
or die "connect: $!\n";

my $ofh = select CLIENT;
$|++;
select $ofh;

print CLIENT $header;

while (<CLIENT>) {
print;
}
__END__

For this particluar site (www.webservicex.net) the result is:

--- start
HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Sun, 16 Oct 2005 16:57:56 GMT
Connection: close
Content-Length: 20

<h1>Bad Request</h1>
--- end

For *every* other site I have tried, it works perfectly. Also
telneting to port 80 using a cut and paste from the $header
defined above actually works - even stranger unless I am
missing something very obvious.

Axel

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM
Wireless connexion problem.. Michel S. Wireless Networking 2 05-21-2005 09:32 PM
SQL Connexion problem... +The_Taco+ ASP .Net 1 10-17-2003 05:01 PM



Advertisments