欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP socket实现和Java端readFully对接

程序员文章站 2024-02-01 18:31:40
...
java:
DataInputStream stream = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
int i=  stream.readInt();
byte[] b = newbyte[i];
stream.readFully(b);
System.out.println(new String(b));

php:

functionwriteInt($socket, $i)
{$data = pack('N', $i); 
    socket_write($socket, $data);
}
writeInt($sock,strlen("ZXCV"));
socket_write($sock,"ZXCV",strlen("ZXCV"));
').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教程有兴趣的朋友有所帮助。