Forum Discussion

Lucas_de_Aguil1's avatar
Lucas_de_Aguil1
Icon for Nimbostratus rankNimbostratus
Oct 02, 2018

TCP::respond works with both ASCII and HEXADECIMAL bases?

Hey guys,

 

I need to send back a message with the command TCP::respond.

 

The message starts with its size in HEXADECIMAL (like 0065) and the rest of the message is in ASCII.

 

That works? Or I have to use another command to do that?

 

  • Like the example below, where the 0065 is hexadecimal and the rest is ascii:

    when CLIENT_DATA {
    
        set message "0065thisisamessage"     
        TCP::respond $message
    
    }
    
  • Maybe this,

    when CLIENT_DATA {
        set message "0065thisisamessage"     
        TCP::respond $message
        TCP::payload replace 0 [TCP::payload length] ""
    }
    

    This is technically how you would respond to a client with TCP data. Maybe the bigger question is if the client accepts it this way.

  • Do you mean concatenate different format type?

    Try

    set message [binary format H4a* 0065 "thisisamessage" ]    
    
    • H4 means second parameter is 4 hex
    • a* means third parameter is binary with not fixed length

    ASCII encoding is binary... so use a* to include ascii string