#!/usr/bin/perl use strict; use IO::Socket; use URI; my $location = shift || "http://openbox:1011/MW"; my $url = new URI( $location ); my $host = $url->host || "openbox"; my $port = $url->port || 1011; my $path = $url->path || "/MW"; my $socket = new IO::Socket::INET (PeerAddr => $host, PeerPort => $port, Proto => 'tcp') or die "Cannot connect to the $host.\n"; $socket->autoflush (1); my $hash = { name => 'sourcer', pass => 'unknown', }; print $socket "POST $path HTTP/1.1","\n"; print $socket "Host: $host","\n\n"; print $socket "hello this is a test sentence"; #print while (<$socket>); $socket->close; #### use strict; use Data::Dumper; use IO::Socket; use Apache2::RequestRec (); use Apache2::Const -compile => ( 'OK', 'NOT_FOUND' ); use Apache2::compat; sub handler { $| = 1; my( $r ) = @_; #$r->content_type("text/html"); my $socket = IO::Socket::INET->new ( Peeraddr => "localhost", BindPort => 1011, Proto => "tcp", type => SOCK_STREAM, Listen => 256 ) or die "Couldn't connect : $@\n"; # wait for a connection my $new_sock = $socket->accept(); while (<$new_sock>) { print $_; } $socket->close;