closed */If ($ buf = shutdown ){Socket_close ($ msgsock );Break 2;}/* The client outputs help information when entering the help Command */If ($ buf = h ){$ Msg = "PHP Server Help Message "."To quit, type quit ."."To shut down the server type shutdown ."."To get help message type help ."."Php> ";Socket_write ($ msgsock, $ msg, strlen ($ msg ));Continue;}/* Message displayed when the command entered by the client does not exist */$ Talkback = "PHP: un
get help message type 'HELP'. \ r \ n "."Php>";Socket_write ($ msgsock, $ msg, strlen ($ msg ));Continue;}/* Message displayed when the command entered by the client does not exist */$ Talkback = "PHP: unknow command '$ buf'. \ r \ nphp>";Socket_write ($ msgsock, $ talkback, strlen ($ talkback ));Echo "$ buf \ n ";} While (true );Socket_close ($ msgsock );} Whil
".
"============================================== ===\ R \ n ".
"Php>";
Socket_write ($ msgsock, $ msg, strlen ($ msg ));
Do {
If (False===( $Buf=Socket_read($ Msgsock, 2048, PHP_NORMAL_READ ))){
Echo "socket_read () failed: reason:". socket_strerror ($ ret). "\ n ";
Break 2;
}
If (! $Buf=Trim($ Buf )){
Continue;
}
/* Close the client connection when the client enters the quit command */
If ($Buf= 'Quit '){
Break;
}
/* When the client enters the shutdown comm
server and the client are closed * *if ($buf = = ' shutdown ') {Socket_close ($msgsock);Break 2;}/* Client input Help command when output assistance information * *if ($buf = = ' h ') {$msg = "PHP Server help message \r\n\r\n"."To quit, type ' quit '." \ r \ n "."To shut down the server type ' shutdown '. \ r \ n"."To get help message type ' help '. \ r \ n"."Php>";Socket_write ($msgsock, $msg, strlen ($msg));Continue}/* Prompt message if client input command does not exist *$
majority of users will choose an option, Then it is best to leave it to the user to choose (the next article will have a specific discussion).
Accessibility
Accessibility is the most overlooked design factor, however, regrettably, my mentor is an expert in this field, and I feel embarrassed not to take this aspect out of the circle, so I still have to say a little more if I know that many designers are b
First, open the socketPhpinfo (); Check to see if the socket extension is turned on, otherwise open in php.ini.Second, the server-side code of the wordingOb_implicit_flush (); $address = ' 127.0.0.1 '; $port = 10005;Creating portsif ($sock = Socket_create (Af_inet, sock_stream, sol_tcp) = = = =False) {echo "Socket_create () Failed:reason: ". Socket_strerror (Socket_last_error ()). "\ n ";}Bindingif (Socket_bind ($sock, $address, $port) = = =False) {echo "Socket_bind () Failed:reason: ". Socket_s
;}///Client Input help command when output assistance information */if ($buf = = h) {$msg = "PHP Server help Message"."To quit, type quit."."To shut down the server type shutdown."."To get help message type Help."."Php>";Socket_write ($msgsock, $msg, strlen ($msg));Continue}/* Prompt message when the client input command does not exist */$talkback = "Php:unknow command $buf .php>";Socket_write ($msgsock, $talkback
($ buf )){Continue;}/* Close the client connection when the client enters the quit command */If ($ buf = 'Q '){Break;}/* When the client enters the shutdown command, both the server and client are closed */If ($ buf = 'shutdown '){Socket_close ($ msgsock );Break 2;}/* The client outputs help information when entering the help command */If ($ buf = 'h '){$ Msg = "PHP Server Help Message \ r \ n "."To quit, type 'quit'. \ r \ n "."To shut down the server type 'shutdown '. \ r \ n "."To get help m
:". Socket_strerror ($result). "\ n";
Break 2;
}
if (! $buf = Trim ($buf)) {
Continue
}/* Client input QUIT command when closing client connection */
if ($buf = = ' Q ') {
Break
}/* Client input Shutdown command when both server and client are off */
if ($buf = = ' shutdown ') {
Socket_close ($msgsock);
Break 2;
}///Client Input help command when output assistance information */
if ($buf = = ' h ') {
$msg = "PHP Server help Me
===$ buf ){
Echo "socket_read () failed: reason:". socket_strerror ($ result). "\ n ";
Break 2;
}
If (! $ Buf = trim ($ buf )){
Continue;
}/* Close the client connection when the client enters the quit command */
If ($ buf = 'Q '){
Break;
}/* When the client enters the shutdown command, both the server and client are closed */
If ($ buf = 'shutdown '){
Socket_close ($ msgsock );
Break 2;
}/* The client outputs help information whe
We know that data passing from parent to child is relatively easy, but it is more difficult to pass from a child process to a parent process.There are many ways to achieve process interaction, and in PHP it is more convenient to communicate in the pipeline. Of course, communication can also be done through Socket_pair.The first is the server in order to respond to every request to do things (send a URL sequence, url sequence with t split. And the end tag is N)function Clienthandle ($msgsock, $ob
First, open the socketPhpinfo (); Check to see if the socket extension is turned on, otherwise open in php.ini.Second, the server-side code of the wordingOb_implicit_flush (); $address = ' 127.0.0.1 '; $port = 10005;Creating portsif ($sock = Socket_create (Af_inet, sock_stream, sol_tcp) = = = =False) {echo "Socket_create () Failed:reason: ". Socket_strerror (Socket_last_error ()). "\ n ";}Bindingif (Socket_bind ($sock, $address, $port) = = =False) {echo "Socket_bind () Failed:reason: ". Socket_s
of code is the code in the program where I implement the communication:
1. 2. Set_time_limit (0);3. $address = "127.0.0.1";4. Ob_implicit_flush ();5./*6. * Created on 2009-9-147. *8. * To change the template of this generated file go9. * Window-preferences-phpeclipse-php-code Templates10. */11. $port = ' 8083 ';13. if ($sock = Socket_create (Af_inet, Sock_stream, sol_tcp)) echo "Socket_create () Failed:reason:". Socket_strerror ($sock). "\ n";16.}17. if ($ret = Socket_bind ($sock, $address, $p
All types and type members have accessibility levels to control whether they can be used in other code in your assembly or in other assemblies. You can use the access modifier to specify the accessibility of a type or member when declaring a type or member.
Public
Any other code in the same assembly, or other assemblies that reference the assembly, can access the type or mem
-network problems. When the charge lock screen can also automatically help us Rob red envelopes. And you know, the accuracy of the machine to rob Red envelopes is 100%, this may be the difference between people and machines. So to ensure that the accuracy of the acquisition is 100%, it depends on our efficient and accurate algorithm implementation. Here's a look at the principle implementation.
When I saw the rush of red envelopes last year, as a developer in the heart of how eager to develop a
All types and type members in C # have accessibility levels to control whether they can be used in other code in your assembly or in other assemblies. You can use the access modifier to specify the accessibility of a type or member when declaring a type or member.
Public
Any other code in the same assembly, or other assemblies that reference the assembly, can acces
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.