I know this thread has long since died, however I figure an answer would be helpful to those who are looking for FilePro port examples.
I didn't really like the FilePro socket control, it seems to be very limiting. However you can easily write out information to files using the jsfile command and port the information over using some very simple PHP. This script was made under a machine running PHP 5.3
jsfile :tx "Hello World"
system "/bin/php /library/port.php"
$argv[1] is the filename and it sends the file to the host and then reads the socket connection for the response given the timeout period.
<?php
date_default_timezone_set("America/Phoenix");
$filepath="/portfiles";
function res_file($trans, $sent) {
global $filepath;
file_put_contents($filepath.$trans.".res", $sent, LOCK_EX);
}
function res_err($trans, $msg) {
global $filepath;
file_put_contents($filepath.$trans."err.res", date("mdy:His")." - ".$msg."\n", FILE_APPEND | LOCK_EX);
exit();
}
$init_micro=microtime(true);
$eof=true;
$host="192.168.1.101";
$port="1022";
$timeout=30;
$infile=(isset($argv[1]))?$argv[1]:"";
if (preg_match("/close/", $infile)){
$timeout=600;
}
$contents="";
if ($infile == ""){
res_err ("", "Error: Need one arguements.");
} else {
try {
$contents=file_get_contents($filepath.$infile.".req");
$contents=trim($contents)."";
} catch(Exception $e) {
res_err ($infile, "Error: Getting file exception.");
}
}
//echo "\nAttempting to connect...";
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout);
stream_set_blocking ($sk, false);
if (!is_resource($sk)) {
res_err ($infile, "Error: connection fail: ".$errnum." ".$errstr);
} else {
//echo "\nConnected; Sending Data...";
fwrite($sk, $contents);
$dati="";
while (!feof($sk) && $eof ) {
if ((microtime(true) - $init_micro) > 15000){
res_err ($infile, "Error: Socket Communication longer than default setting allowed.");
}
$dati.= fread ($sk, 4096);
$eof=(preg_match("/99,\"\"/i", $dati))?false:true;
//echo "\nConnected; Getting Data...".$dati;
}
}
//echo "\nConnected; Closing Socket...";
fclose($sk);
//echo "\nConnected; Writing file...";
res_file($infile, $dati);
//echo($dati);
?>