I have doubt about vec function .
+ what vec() does here ?
+ Without calling vec() function also this piece of code work fine what i have expected .
+ split (//, unpack("b*", $OutputBuffer)) what it does?
use IO::Select; use IO::Socket; $lsn = new IO::Socket::INET(proto => 'tcp', Listen => 1, LocalAddr => + '192.168.6.92:9090', Reuse => 1); print "Error in socket :$!\n"; $sel = new IO::Select( $lsn ); $i = 0; $IPHASH= {}; while(@ready = $sel->can_read) { foreach $fh (@ready) { if($fh == $lsn) { # Create a new socket $new = $lsn->accept; $HostAdd = $new->peername(); ($Port , $Myadd) = sockaddr_in($HostAdd); $IPAdd = inet_ntoa($Myadd); $sel->add($new); $IPHASH->{"$IPAdd"} = $new; } else { # Process socket $InputBuffer; $OutputBuffer; $Delay = 0.1; vec($InputBuffer, fileno($fh),1)=1; ($Found, $Temp) = select($OutputBuffer=$Inp +utBuffer, undef, undef, $Delay); my (@Bits) = split (//,unpack("b*", $OutputBuffer)); $handle = fileno($fh); recv ($fh, $Received_Message, 20, 0); $HostAdd = $new->peername(); ($Port , $Myadd) = sockaddr_in($HostAdd); $IPAdd = inet_ntoa($Myadd); $fh = $IPHASH->{$Received_Message}; #vec($InputBuffer, fileno($fh), 1)=1; #($Found, $Temp) = select($OutputBuffer=$I +nputBuffer, undef, undef, $Delay); # my (@Bits) = split (//, unpack("b*", $Out +putBuffer)); # $handle = fileno($fh); print "::: $Received_Message :::: \n"; $fh->autoflush(1); # Maybe we have finished with the socket $sel->remove($fh); $fh->close; } $i++; } }

In reply to vec and unpack by dharanivasan

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.