Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've not done this with PHP before, but my first guess would be that you are getting a binary string back, which you'll need to convert into ASCII (or whatever character set you're using).</p> <p>It looks like you should be able to use PHP's <a href="http://php.net/unpack" rel="nofollow">unpack</a> for this.</p> <p>It's hard to know exactly what format to provide pack without knowing what data you're getting back. It looks like unpack would at least be able to give back an array of decimal values (assuming you're getting characters back), which you could then convert into ASCII, with <a href="http://www.php.net/manual/en/function.chr.php" rel="nofollow">chr</a>. It might be something like this:</p> <pre><code>//Receive some data $r = socket_recvfrom($sock, $buf, 512, 0, $remote_ip, $remote_port); //Convert to array of decimal values $array = unpack("c*chars", $buf); //Convert decimal values to ASCII characters: $chr_array = array(); for ($i = 0; $i &lt; count($array); $i++) { $chr_array[] = chr($array[$i]); } </code></pre> <p>It depends on the protocol design as to how complex your parsing of the binary data needs to be (That is, are you just sending string data, or a mix of integers and strings, etc... You need to parse the binary data accordingly).</p> <p><strong>EDIT:</strong> I've updated the format string to match an indefinite number of characters, using the array element name 'chars' as per the format listed <a href="http://php.net/pack" rel="nofollow">here</a>.</p> <p><strong>EDIT:</strong> Added some elementary ASCII conversion to code example.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload