我是套接字连接的新手,我想向套接字服务器发送一些命令,但我只能发送第一条消息而不是其他消息。
客户:
$fp = stream_socket_client("tcp://127.0.0.1:1000", $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$cmd_1 = "hello";
fwrite($fp, $cmd_1);
while (!feof($fp)) {
print_r(fgets($fp, 1024));
}
$cmd_2 = "second message";
fwrite($fp, $cmd_2);
while (!feof($fp)) {
print_r(fgets($fp, 1024));
}
fclose($fp);
}
Run Code Online (Sandbox Code Playgroud)
如何发送多条消息,例如 first $cmd_1,取决于结果,我必须发送$cmd_2?
服务器
error_reporting(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
/* Turn on implicit output flushing so we see what we're getting
* as it comes in. …Run Code Online (Sandbox Code Playgroud) 我试图通过python imaplib搜索"10分钟以上"的电子邮件我可以搜索任何字符串的电子邮件,但不是日期.
result, data = mail.uid('search', None, '(HEADER Subject "SEARCH_TERM")')
Run Code Online (Sandbox Code Playgroud)
我怎样才能在几分钟内进行搜索?