www-thermferm/utilities.php

changeset 251
173b4480c4a0
parent 196
4d7a96c5d1ff
child 255
fb930d1db5a6
equal deleted inserted replaced
250:a21865cb1ef4 251:173b4480c4a0
48 $sock = open_socket(); 48 $sock = open_socket();
49 if ($sock == false) { 49 if ($sock == false) {
50 return ""; 50 return "";
51 } 51 }
52 socket_write($sock, $command, 4096); 52 socket_write($sock, $command, 4096);
53
54 $answer = "";
55 while (1) {
56 $line = socket_read($sock, 4096);
57 if ($line === '')
58 break;
59 $answer .= $line;
60 }
61 socket_close($sock);
62
63 return $answer;
64 }
65
66
67
68 /*
69 * @param string array of $commands to send to the server.
70 * Return: string with the complete reply from the
71 * server. This can be a multiline reply.
72 */
73 function send_array($command)
74 {
75 $sock = open_socket();
76 if ($sock == false) {
77 return "";
78 }
79
80 foreach($command as $cmd) {
81 socket_write($sock, $cmd, 4096);
82 usleep(20000); /* Give server time to recognize lines */
83 }
53 84
54 $answer = ""; 85 $answer = "";
55 while (1) { 86 while (1) {
56 $line = socket_read($sock, 4096); 87 $line = socket_read($sock, 4096);
57 if ($line === '') 88 if ($line === '')

mercurial