ph_sendsocketdata1 PowerHome formula function
Description
Sends and retrieves data using a socket to a remote IP/ Port.
Syntax
ph_sendsocketdata1 ( url, port, flags, data )
Argument |
Description |
url
|
String. The IP or hostname of the remote device to communicate with.
|
port
|
Long. The Port of the remote device to communicate with.
|
flags
|
Integer. Flags controlling how the
function performs. Indivdual flag values are added together to create the
Flags value. Add 1 to have the function return on
"SendComplete". Add 2 to have special characters translated
before sending. Add 4 to have special characters returned translated. Add 8 to have the function return when data is received. You should not use 1 and 8 together as they mutually exclusive. If neither 1 or 8 are added to the flags parameter, then the function will return when the connection is closed.
|
data
|
String. The data to send via a socket to the remote device.
|
Return value
String. Returns data from the remote device. If an error occurs, it will be in the form: "*ERROR* - XXX". Special characters can be sent using this function by converting them to 3 digit ASCII and escaping the sequence with a '\' character. So to send a carriage return as part of the data, use \013 and be sure to include a 2 in the flags sum. If the data being returned by the function is likely to contain characters outside of the normal character range (32 to 125) then add a 4 to the flags sum so that these characters will be returned in the escaped 3 digit ASCII form. Keep in mind if you are using escaped characters that the backslash character (\) must now be escaped as \092.
You may also encode special characters in a hexadecimal format rather than a decimal format. In this case, the escape sequence consists of the "\" character followed by either an upper or lower case "x" followed by two upper or lower case hexadecimal digits. A carriage return using the hex format would be \x0D. You must also include a 2 in the flags sum as is the case with decimal escape codes.
Usage
Use this funciton to send and receive raw data using sockets.