Allready solved , get solution from DroopSnoot, $sulfix = sprintf(“%c%c%c%c”, 255, 254, 253, 252);
I have a task, to send a message with ending sulfix. If the message like $Message=“abcdef”
how to write code with php, thx before
Suffix in hexadecimal format is : {FF, FE, FD, FC}
The message structure can be viewed at the message format section.
Suffix is a byte array delivered after the instruction message was sent. The format of suffix delivered
should follow the below format.
What is in your hex2bytearray() function? I can’t find anything to suggest that is a standard part of PHP, and I wondered why you could convert each individual byte to a byte array.
Can’t you use sprintf() to add the characters to the end? Something like
Your vendor should have instructions on how to interact with their service, if they do not, you need to ask clarifying questions. From the look in the first post, this is for an ongoing transport system, i.e. message, message, message etc.
For example, the first post explains a “message delivered” sequence/code.
In the post above, you add this directly to the end of your message.
Have you tried sending the message delivered code, after you sent the actual message, in a new socket_write command? I would also confirm if the message should be encoded before sending as well.
I am also not sure if your format of the message delivered code is correct.
Your next step should be as mentioned above, getting the instructions from the provider, or asking questions to clarify how each part should be delivered.
Fundamentally, the interpretation of the material exchanged between the two sides of the connection must be agreed upon. It is a protocol to do this.
The first two bytes could be interpreted as an integer, as indicated. Ensure that both parties can agree on which byte is high and which is low (the endianness of the number). This method also stops you from sending continuous strings that are greater than 65k bytes. It probably won’t be an issue, but it’s something to be aware of.