Since your post contains keywords like hashes, tcp, serialized data, compression, Tk, etc.
I might mention
Net::EasyTCP. It will automatically serialize hashes for you, has a choice of compression and encryption, and port passwords for more security.
See
ztk-enchat encrypted server client for how to use it with Tk. Basically, you setup a Tk timer to run a do_one_loop in the server, so both eventloops run simultaneously.
$server = new Net::EasyTCP(
host => $host,
mode => 'server',
port => $port,
password => $portpassword, # if using asymmetric encryption,
# use a port password for better secur
+ity
donotencryptwith => \@nocrypt,
# donotencrypt => 1,
# donotcompresswith => \@nocompress,
# donotcompress => 1,
)
|| die "ERROR CREATING SERVER: $@\n";
$server->setcallback(
data => \&gotdata,
connect => \&connected,
disconnect => \&disconnected,
)
|| die "ERROR SETTING CALLBACKS: $@\n";
# start server up
$server->do_one_loop() || die "ERROR looping SERVER: $@\n";
&displayit($rotext,'Server started at '.&gettime()." on port $port\n")
+;
# start main listening loop for Tk
$loop = $mw->repeat(11,
sub {
$server->do_one_loop();
$mw->idletasks;
if($serverstopflag){ &kill_server }
} );
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.