Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Posted by ChrisS (ChrisS), 11 December 2003
My application currently recieves data via TCP/IP sockets.

However I now need to investigate accepting HTTP messages.

Is there a module on the CPAN that anyone knows of that could help me?

Posted by ChrisS (ChrisS), 11 December 2003
I have found:
LWP - But is this only for client side.. or can I use the tools provided in reverse?

also just literally:
I have no idea what this is yet...

Any ideas?

Posted by admin (Graham Ellis), 11 December 2003
Hi, Chris .. at the risk of being branded a politician who answers only the questions he wants to rather than the question that was asked ...  here's a web server written in Perl that uses only the Socket module that's a part of the standard distribution and one of our own modules to filter.   Might provide you with some food for thought.  Not sure about modules - I've not bothered for this sort of thing!


# httpd requests - echo server

use Socket;
use whc_filter;

# Set up listener

$on_port = 8080;
$proto = getprotobyname("tcp");

socket (Server, PF_INET, SOCK_STREAM, $proto) ||
               die ("socket");
setsockopt(Server, SOL_SOCKET,SO_REUSEADDR,1) ||
               die ("setsockopt");
$pbind = sockaddr_in($on_port,INADDR_ANY) ||
               die ("sockaddr_in");
bind(Server,$pbind) ||
               die ("bind");
listen(Server,SOMAXCONN) ||
               die ("listen");

# await a contact

@response = <DATA>;

while ($paddr = accept(Client, Server)) {
       while (<Client>) {
               push @gotten,$_;
               if ($_ =~ /^\s*$/) { last;}
               ($f,$v) = split(/\s+/,$_,2);
               $param{lc($f)} = $v;

       if ($gotten[0] =~ /^POST/) {

       print Client @response;
       print Client @gotten,"</PRE>";
       if ($gotten[0] =~ /^POST/) {
               ($dsay .= $&."<BR>") while ($data =~ s/^(.{1,80})//);
               print Client "<H4>Posted Data:</H4><CODE>\n";
               print Client $dsay,"</CODE>";
       print Client "</BODY></HTML>\n";
       close Client;
       $#gotten = -1;
       undef %param;

HTTP/1.0 200 OK
Date: Sun, 18 Apr 1999 13:59:18 GMT
Server: Well House Consultants / PAN 1.0
Content-type: text/html

<BODY bgcolor=white text=black>
You have contacted the Server Echo Service that tells you what
your browser sent in its request!<P>
<H2>The Data provided to the server was:</H2>

and the module

package whc_filter;

# HTML filters.

require 5.003;
use strict;

# scrub encodes & < and > in an array into ISO characters
# Also replaces hard new line characters with <P> and <BR>

sub scrub  (\@) {
       my ($svar,$k);
       $svar = \@_;
       for ($k=0;$k<=$#{$svar};$k++) {
       s/\n\r/\n/g; # dos to standard
       s/\r/\n/g; # mac to standard
       $svar->[$k] = $_;


Posted by ChrisS (ChrisS), 11 December 2003
Thanks Graham..

I'll look into that..

I think Mr O'reilly's book may come in handy on some of thoughs calls!!

Perhaps I can give you a shout if I get stuck


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho