Execute a command
1 function Do_command ($command, $code)
2 {
3 $this-$#@62;lastact= $command;
4 $this-$#@62;show_debug ($this-$#@62;lastact, "out");
5 fputs ($this-$#@62;fp, $this-$#@62;lastact);
6 $this-$#@62;lastmessage = fgets ($this-$#@62;FP, 512);
7 $this-$#@62;show_debug ($this-$#@62;lastmessage, "in");
8 if (!ereg ("^ $code", $this-$#@62;lastmessage))
9 {
Ten return false;
11}
Else
return true;
14}
In the Socket Processing section, it is found that some commands are handled very similarly, such as the Helo,mail from,rcpt to,quit,data command, which requires that the relevant content be displayed based on whether the debug information is displayed, and that the response code returned, if desired, should continue processing, If it is not expected, the rationale should be interrupted. So for clarity and simplification, a generic handler is written specifically for the processing of these commands.
The function's parameters are $code to the desired response code, and if the response code is the same, the processing succeeds, otherwise an error occurs.
The 3rd Line records the final execution of the command.
Line 4th, display the upload command.
Line 5th, use fputs to actually transfer instructions to the server.
On line 6th, the response information received from the server is placed in the last response message variable.
The 7th line displays the response information.
Line 8th, determines whether the response information is expected, if it is the 13th row returns success (true), otherwise the 10th row returns failure (false).
This function, on the one hand, completes the sending and displaying function of the instruction and information, and does not determine the success of the returned response.
http://www.bkjia.com/PHPjc/531798.html www.bkjia.com true http://www.bkjia.com/PHPjc/531798.html techarticle executes a command 1 function do_command ($command, $code) 2 {3 $this-$#@62;lastact= $command; 4 $this-$#@62;show_debug ($this-$#@ 62;lastact, "out"); 5 fputs ($this-$#@62;fp, $this-...