Packets between PHP and C++
Posted: Thu Jul 27, 2006 10:25 pm
When a packet is created in C++, it looks like this:
When a packet is created in PHP, it looks like this:
Of course, nomatter what language it is that you are sending a packet in, it is still just a string of data. And this string of data can be viewed in many different ways such as hex or ASCII.
What I don't understand is how to handle packets that have been created using STARTPACKET in C++ with PHP's socket_read and socket_write functions. Socket_read() and socket_write() deal with a string. STARTPACKET is very complicated. I've been told that STARTPACKET uses some header to identify what packet it is. Is there a way to identify packets using headers in PHP? I've seen some functions such as pack and unpack that look useful, but I have NO idea how to use them to do this.
I just need to communicate with a program written in C++ using winsock with PHP.
Code: Select all
STARTPACKET(pak,0x782,0x09);
SETBYTE( pak, 0x00, 0x23);
SETBYTE( pak, 0x01,0x00);
SETBYTE( pak, 0x03, 0x53);
SETWORD( pak, 0x04, 0x0200);Code: Select all
socket_write ( $sock, "test", strlen ( "test" ) );What I don't understand is how to handle packets that have been created using STARTPACKET in C++ with PHP's socket_read and socket_write functions. Socket_read() and socket_write() deal with a string. STARTPACKET is very complicated. I've been told that STARTPACKET uses some header to identify what packet it is. Is there a way to identify packets using headers in PHP? I've seen some functions such as pack and unpack that look useful, but I have NO idea how to use them to do this.
I just need to communicate with a program written in C++ using winsock with PHP.