Sending Inband Replies
|Top Previous Next|
How to generate inband reply correctly
Inband replies are sent from the RPL buffer. Unlike the process of sending "regular" TX data that requires you to use sock.setdata and sock.send methods, the process of sending an inband reply only takes one step. You set and send (commit) the data with a single method- sock.setsendinband.
The sock.setsendinband method puts the data into the RPL buffer and immediately commits it for sending. The socket does not add necessary incapsulation automatically: it is the responsibility of your application to add the escape character, some other character after the escape, and the end character.
Your inband reply will only be stored into the RPL buffer if the latter has enough space to store your entire message. If there is not enough free space then nothing will be stored. This is different from the TX buffer, for which whatever can fit is stored. You can check the free space in the RPL buffer by using the sock.rplfree property. Amount of unsent data in the RPL buffer can be checked through the sock.rpllen property.
You must not split your inband reply- it must be placed in the RPL buffer with a single invocation of sock.setsendinband. In the example below we reply back "OK" to each inband command we receive:
And this would be an incorrect way- do not split inband replies!
sock.setsendinband(" OK") 'WRONG!