Was there a perl question in there somewhere?

By "write" I meant "in perl". Consider it a learning experience. Also, all I need is something that will run scripts from a cgi-bin locally based on a singular, established connection. Having never used apache, I figured that by the time I understand it I could have written something to do this (in perl).

This is what I have so far based on various examples:
#!/usr/bin/perl -w use strict; # simple server use Socket; use IO::Handle; socket(SERV, PF_UNIX, SOCK_STREAM,0); unlink "/tmp/testsock"; bind(SERV,sockaddr_un("/tmp/testsock")) or print "ERROR!"; listen(SERV,1); while (accept(CLIENT,SERV)) { CLIENT->autoflush(1); print CLIENT "Hi there!\n"; my $answer = <CLIENT>; print $answer; }
and
#!/usr/bin/perl -w use strict; # simple client use Socket; use IO::Handle; socket(TSOCK, PF_UNIX, SOCK_STREAM,0); connect(TSOCK, sockaddr_un("/tmp/testsock")) or print("ERROR!"); while (defined(my $messg = <TSOCK>)) { print $messg; print TSOCK "Hello server!"; TSOCK->flush; }
This works to the point where the server should recieve and print the answer from the client -- it doesn't. The initial "Hi there!" is recieved and printed tho. Once I can get back and forth communication working, I should be able to figure out what to do next.

Being kind of a luddite, I preferred not to use IO::Socket for the learning experiment.

In reply to Re^2: local webserver for CGI on linux by my_nihilist
in thread local webserver for CGI on linux by my_nihilist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.