Recently in PHP to do about the socket communication related content, found that many people on the network to understand how to carry out 16, research, the code below, welcome to shoot bricks.
Copy CodeThe code is as follows:
$SENDSTR = ' 30 32 30 34 03 30 33 '; 16 Binary data
$sendStrArray = Str_split (Str_replace (",", $sendStr), 2); Converting 16 of binary data into two arrays
$socket = Socket_create (Af_inet, Sock_stream, Getprotobyname ("TCP")); Create socket
if (Socket_connect ($socket, "192.168.1.100", 8080)) {//connection
for ($j = 0; $j < count ($sendStrArray); $j + +) {
Socket_write ($socket, Chr (Hexdec ($sendStrArray [$j])); Send data by group
}
$RECEIVESTR = "";
$RECEIVESTR = Socket_read ($socket, 1024x768, php_binary_read); Receive data in 2 binary mode
$receiveStrHex = Bin2Hex ($RECEIVESTR); Convert 2 binary data to 16 binary
echo "Client:". $receiveStrHex;
}
Socket_close ($socket); Close socket
?>
http://www.bkjia.com/PHPjc/328168.html www.bkjia.com true http://www.bkjia.com/PHPjc/328168.html techarticle recently in PHP to do about the socket communication related content, found that many people on the network to understand how to carry out 16, research, the code below, welcome to shoot bricks. Copy code code such as ...