BrowserUk,

I use IO::Socket::UNIX for both the client and server. The routines are almost exactly the same as the perl documentation: Note: I typed this code in, so I doubt it will compile and this is just part of a lot of other code.

Server:

use IO::Socket::UNIX; use strict; my $server = new IO::Socket::UNIX -> new ( Local => "$ROOT/envSocket +", Type => SOCK_STREAM, Reuse => 1, Listen => 147 ); [ ... error handling ... ] while ( 1 ) { my $client = $server => accept(); if ( defined $client ) { eval { while(<$client>) { $Todo .= $_; chomp($Todo); } } if ( $@ ) { ... } if ( $Todo ) { ... process work ... } close $client; } }

Client:

use IO::Socket::UNIX; use strict; my $server = new IO::Socket::UNIX -> new ( Peer => "$ROOT/envSocket +", Type => SOCK_STREAM, Timeout => 10 ); [ ... error handling ... ] print $server "$Todo\n"; shutdown ( $server, 1 ); while ( <$server> ) { $answer .= $_; } shutdown ( $server, 2 ); close $server; ... }

Even if I mistyped the code, the actual code works as expected. But the process is a lot slower than I had expected. Here are some results:

50,000 records processed: ( results are number/second ) 1 process | client/server Writes: 2,953 | 1,152 ReadNext: 35,138 | 2,870 ReadPrev: 34,236 | 2,616

So, if I could keep a persistent connection between the server and the client then performance may be better. Everything I have tried has just hung. Some information supplied by zentara has given me some new ideas.

Any help will be greatly appreciated.

Thank you

"Well done is better than well said." - Benjamin Franklin


In reply to Re^2: How to maintain a persistent connection over sockets? by flexvault
in thread How to maintain a persistent connection over sockets? by flexvault

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.