On Wed, May 18, 2011 at 3:16 PM, Schlager, Christian <schlager@xxxxxxxx>wrote: > > > Hello, > > I am a first-time poster. I hope this is the proper way to ask my question: > > I have a C++ media player application that I want to control via a php > website. > To that end the application has an UDP socket listening for Player > messages. > In C++ player messages have the following members: > > class MessageHeader > { > UINT16 packetSize; // size of message in bytes > including header > UINT16 sequenceNum; // sequence number of message > UINT16 flags; // flags > UINT16 msgType; // msg type > } > > class PlayerCommand : public MessageHeader > { > WCHAR command[MAX_PATH]; // dynamic string > } > > > The php website is supposed to create an UDP socket in order to send player > commands (play, stop, next, etc.) > However, according to the documentation all php socket functions only take > messages in string format. > For example, int socket_sendto ( resource $socket , string $buf , int $len > , .... > > > My question is this: > If it is possible at all, how can I create a $buf - string that represents > the PlayerCommand class and is accepted by the C++ listening socket? > You really want something like JSON, Thrift (http://thrift.apache.org/), XML or some other format to package the data in a way that will be easily manipulated at both ends, rather than trying to duplicate the in-memory representation that your particular C++ compiler of choice is using. Doing things that way leads to an extremely fragile system. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/