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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.