The desired function is as follows: execute a task on the PHP page of the client, such as creating a site, notifying the backend nc listener in some way, and then executing the relevant script, it is better to create an ftp account and create a directory. But how can I send messages to nc through php? The function to be implemented is as follows:
On the PHP page of the client, execute a task, such as creating a site, notifying the backend nc listener in some way, and then executing related scripts. It is better to create an ftp account and create a directory.
But how can I send messages to nc through php?
Ask for advice!
The following are the php clients:
$fp = fsockopen ("udp://127.0.0.1",40030,$errno,$errstr,30);if(!$fp){ echo "$errstr ($errno)
";}else{ fwrite($fp,"Hello nc"); echo "Success"; fclose($fp);}
The following is the shell Server:
#!/bin/bashkillall 'nc' >/dev/null 2>&1nc -l -u 40030 | while read Linedo echo $Linedone
But why not output it?
Reply content:
The following functions are implemented:
On the PHP page of the client, execute a task, such as creating a site, notifying the backend nc listener in some way, and then executing related scripts. It is better to create an ftp account and create a directory.
But how can I send messages to nc through php?
Ask for advice!
The following are the php clients:
$fp = fsockopen ("udp://127.0.0.1",40030,$errno,$errstr,30);if(!$fp){ echo "$errstr ($errno)
";}else{ fwrite($fp,"Hello nc"); echo "Success"; fclose($fp);}
The following is the shell Server:
#!/bin/bashkillall 'nc' >/dev/null 2>&1nc -l -u 40030 | while read Linedo echo $Linedone
But why not output it?
Because the Bash read command is Read a line from the standard input and split it into fields.
Therefore, you need to output a line break:fwrite($fp,"Hello nc\n");
In addition, why don't you directly use popen to execute scripts in PHP? Close the nc connection and close it.
Why is the backend using nc? the backend can also be written in PHP, for example, using service frameworks such as workerman?
I don't know what you are doing. However, if you mention security, you must either use UDP or add verification and integrity check on your own. In particular, you actually use nc to process UDP, so the message boundary is gone.