Hello flexvault,

Thank you for your time and effort reading and replying to my question/commends. You are absolutely right about it, as I said this is a brief idea that needs experimentation to become generic and more solid.

My assumption was build upon the user reads the length of the string (e.g. 40 characters) creates a string for transmission containing this number.

For example $msg = $length . " " . $txt;. So when the receiver will get the message he knows that he needs to subtract the $length from the length($msg); in order to get the pure message which would be something like 40 character + 3 (length description with the space) = 43 characters. So if the user skips the first 3 characters of the message and reads the rest 40 can know that he got the whole message. Even in case the message was segmented.

Well this is only a brief idea that I was planning to implement.

Sample of code of my idea by using substr including the output:

#!/usr/bin/perl use strict; use warnings; my $msg = "This is just a sample of message."; my $length = length($msg); my $number = length($length); print "\$number: ".$number."\n"; my $transmit = $length . " " . $msg; print "\$transmit: ".$transmit."\n"; my $receive = substr $transmit, 3; print "\$receive: ".$receive."\n"; __END__ $number: 2 $transmit: 33 This is just a sample of message. $receive: This is just a sample of message.

The solution as it is right now, can not be generic, because the receiver needs to know how many digits need to subtract from the $msg. In case that someone wants to make a generic solution, I would recommend the user to read the string and get the actual length before subtracting. As I said, it needs some small experimentation to become generic and more solid solution, but I think it is possible as an idea to be implemented.

Again thank you for your time and effort reading and replying to my query.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^4: how to control segmented messages in TCP chat client by thanos1983
in thread how to control segmented messages in TCP chat client by thanos1983

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.