in reply to How do I create a variable length byte array for socket transmission?
You're using numerical addition rather than string concatenation. try the following instead:$iPkt = “1“; for ( $i = 1; $i < $pktSize; $i++ ) { $iPkt += "1"; }
or even better, replace the whole loop with$iPkt .= "1";
Finally, if you want to send data more complex than just a stream of ASCII "1"s, especially binary data, then you may want to check out the pack() function.$iPkt = “1“ x $pktSize;
Dave.
|
|---|