is it possible to make a c-like binary data(structure) in PHP
Yeah, it's totall possible to construct binary data with PHP, although a bit, no, a lot, less elegant than with C. You need the pack/unpack functions, that let you write binary buffers from php variables. see http://php.net/manual/en/function.pack.php
I've implemented UDP servers and clients for binary protocols (even encrypted) in the past, it's ugly but it works. the only thing you should be careful with is endianness.
receiving reversed data in c socket programming
In your Server program you need to convert response header integers to from host byte stream to network order. You should use htons()
or htonl()
on it first. If you're receiving an integer in clinet, you should use ntohs()
or ntohl()
.
Related Topics
How to Get Beanstalkd Queue to Work for PHP
Strip All HTML Tags, Except Allowed
What Does This Symbol Mean in PHP <=
How to Enable PHP's Openssl Extension to Install Composer
How to Logout from a Session in PHP
Sort an Array by a Child Array's Value in PHP
Transpose 2D Array, Join Second Level with Commas, and Join First Level with Pipes
How to Call a Closure That Is a Class Variable
Header in PDF Page Using Dompdf in PHP
How to Check If There Is a There Is a Wget Instance Running
PHP Remove Special Character from String
PHP Add Element to Every Sub Array of Multi Dimension Array
How to Write a Stored Procedure Using PHPmyadmin and How to Use It Through PHP
How to Get the Client's Ip Address in a PHP Webservice
Recursively Remove Empty Elements and Subarrays from a Multi-Dimensional Array