www-thermferm/utilities.php

changeset 251
173b4480c4a0
parent 196
4d7a96c5d1ff
child 255
fb930d1db5a6
--- a/www-thermferm/utilities.php	Mon Aug 18 20:00:30 2014 +0200
+++ b/www-thermferm/utilities.php	Wed Aug 20 12:02:49 2014 +0200
@@ -66,6 +66,37 @@
 
 
 /*
+ * @param string array of $commands to send to the server.
+ * Return: string with the complete reply from the
+ *         server. This can be a multiline reply.
+ */
+function send_array($command)
+{
+    $sock = open_socket();
+    if ($sock == false) {
+	return "";
+    }
+
+    foreach($command as $cmd) {
+	socket_write($sock, $cmd, 4096);
+	usleep(20000);	/* Give server time to recognize lines */
+    }
+
+    $answer = "";
+    while (1) {
+	$line = socket_read($sock, 4096);
+	if ($line === '')
+	    break;
+	$answer .= $line;
+    }
+    socket_close($sock);
+
+    return $answer;
+}
+
+
+
+/*
  * @param string $command to send to the server.
  * Return: 0 = Ok.
  *         1 = Server responden with an error.

mercurial