java:
<code>DataInputStream stream = <span>new</span> DataInputStream(<span>new</span> BufferedInputStream(socket.getInputStream())); <span>int</span> i= stream.readInt(); <span>byte</span>[] b = <span>new</span><span>byte</span>[i]; stream.readFully(b); System.<span>out</span>.println(<span>new</span> String(b));</code>
php:
<code><span><span>function</span><span>writeInt</span><span>(<span>$socket</span>, <span>$i</span>)</span> {</span><span>$data</span> = pack(<span>'N'</span>, <span>$i</span>); socket_write(<span>$socket</span>, <span>$data</span>); } writeInt(<span>$sock</span>,strlen(<span>"ZXCV"</span>)); socket_write(<span>$sock</span>,<span>"ZXCV"</span>,strlen(<span>"ZXCV"</span>)); </code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了PHP socket實作和Java端readFully對接,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。