Ïê½âphpµÄsocketͨÐÅ

5年以前  |  阅读数:929 次  |  编程语言:PHP 

¶Ô TCP/IP ¡¢ UDP ¡¢ Socket ±a³ÌÕaÐ(C)´ÊÄa²»»aºÜÄ°Éu°É£¿Ëae×ÅÍøÂç¼¼ÊoµÄ*¢Õ¹£¬ÕaÐ(C)´Ê³a³a×ÅÎÒÃǵĶu¶a¡£

ÄÇʲôÊÇTCP/IP¡¢UDP£¿
TCP/IP£¨Transmission Control Protocol/Internet Protocol£(C)¼´´«Êa¿ØÖÆЭÒe/Íø¼aЭÒe£¬ÊÇÒ»¸o¹¤Òµ±e×¼µÄЭÒe¼¯£¬ËuÊÇΪ¹aÓoÍø£¨WANs£(C)Ée¼ÆµÄ¡£
UDP£¨User Data Protocol£¬Óû§Êý¾Ý±¨Ð­Òe£(C)ÊÇÓeTCPÏa¶ÔÓ¦µÄЭÒe¡£ËuÊÇÊoÓÚTCP/IPЭÒe×aÖеÄÒ»ÖÖ¡£
ÕaÀiÓÐÒ»ÕÅͼ£¬±iÃ÷ÁËÕaÐ(C)ЭÒeµÄ¹Øϵ¡£

TCP/IPЭÒe×a°uÀ¨ÔËÊa²a¡¢ÍøÂç²a¡¢Á´Â*²a¡£ÏÖÔÚÄaÖªµÀTCP/IPÓeUDPµÄ¹ØϵÁË°É¡£
SocketÔÚÄÄÀiÄØ£¿
ÔÚͼ1ÖУ¬ÎÒÃÇûÓп´µ½SocketµÄÓ°×Ó£¬ÄÇôËuµ½µ×ÔÚÄÄÀiÄØ£¿»¹ÊÇÓÃͼÀ´Ëµ»°£¬Ò»Ä¿ÁËÈ»¡£

Ô­À´SocketÔÚÕaÀi¡£
SocketÊÇʲôÄØ£¿
¡¡¡¡SocketÊÇÓ¦ÓòaÓeTCP/IPЭÒe×aͨÐŵÄÖмaÈi¼þ³eÏo²a£¬ËuÊÇÒ»×e½Ó¿Ú¡£ÔÚÉe¼ÆģʽÖУ¬SocketÆaʵ¾ÍÊÇÒ»¸oÃÅÃaeģʽ£¬Ëu°Ñ¸´ÔÓµÄTCP /IPЭÒe×aÒþ²ØÔÚSocket½Ó¿ÚºoÃae£¬¶ÔÓû§À´Ëµ£¬Ò»×e¼oµ¥µÄ½Ó¿Ú¾ÍÊÇÈ«²¿£¬ÈÃSocketÈ¥×eÖ¯Êý¾Ý£¬ÒÔ*uºÏÖ¸¶¨µÄЭÒe¡£
Äa»aʹÓÃËuÃÇÂð£¿
¡¡¡¡Ç°ÈËÒѾ­¸øÎÒÃÇ×oÁ˺öaµÄÊÂÁË£¬ÍøÂç¼aµÄͨÐÅÒ²¾Í¼oµ¥ÁËÐi¶a£¬µ«±Ï¾¹»¹ÊÇÓÐͦ¶a¹¤×÷Òª×oµÄ¡£ÒÔÇ°Ìýµ½Socket±a³Ì£¬¾oµÃËuÊDZȽϸßÉiµÄ±a³Ì֪ʶ£¬µ«ÊÇֻҪŪÇaSocket±a³ÌµÄ¹¤×÷Ô­Ài£¬ÉñÃصÄÃaeÉ´Ò²¾Í½Ò¿ªÁË¡£
¡¡¡¡Ò»¸oÉu»iÖеij¡¾°¡£ÄaÒª´oµç»°¸øÒ»¸oÅoÓÑ£¬ÏȲ¦ºÅ£¬ÅoÓÑÌýµ½µç»°ÁaÉuºoÌaÆðµç»°£¬ÕaʱÄaºÍÄaµÄÅoÓѾͽ¨Á¢ÆðÁËÁ¬½Ó£¬¾Í¿ÉÒÔ½²»°ÁË¡£µÈ½»Á÷½aÊø£¬¹Ò¶Ïµç »°½aÊø´Ë´Î½»Ì¸¡£ Éu»iÖеij¡¾°¾Í½aÊÍÁËÕa¹¤×÷Ô­Ài£¬Ò²ÐiTCP/IPЭÒe×a¾ÍÊǵ®ÉuÓÚÉu»iÖУ¬ÕaÒ²²»Ò»¶¨¡£

¡¡¡¡ÏÈ´ÓþÎñÆ÷¶Ë˵Æð¡£þÎñÆ÷¶ËÏȳoʼ»¯Socket£¬È»ºoÓe¶Ë¿Ú°o¶¨(bind)£¬¶Ô¶Ë¿Ú½øÐмaÌý(listen)£¬µ÷ÓÃaccept×eÈu£¬µÈ´ý ¿Í»§¶ËÁ¬½Ó¡£ÔÚÕaʱÈç¹uÓиo¿Í»§¶Ë³oʼ»¯Ò»¸oSocket£¬È»ºoÁ¬½ÓþÎñÆ÷(connect)£¬Èç¹uÁ¬½Ó³É¹¦£¬Õaʱ¿Í»§¶ËÓeþÎñÆ÷¶ËµÄÁ¬½Ó¾Í½¨Á¢ÁË¡£¿Í»§ ¶Ë¢ËÍÊý¾ÝÇeÇo£¬þÎñÆ÷¶Ë½ÓÊÕÇeÇo²¢´¦ÀiÇeÇo£¬È»ºo°Ñ»ØÓ¦Êý¾Ý*¢Ë͸ø¿Í»§¶Ë£¬¿Í»§¶Ë¶ÁÈ¡Êý¾Ý£¬×iºo¹Ø±ÕÁ¬½Ó£¬Ò»´Î½»»¥½aÊø¡£

socketÏa¹Øº¯Êý£º
----------------------------------------------------------------------------------------------
socket_accept() ½ÓÊÜÒ»¸oSocketÁ¬½Ó
socket_bind() °Ñsocket°o¶¨ÔÚÒ»¸oIPµØֺͶ˿ÚÉÏ
socket_clear_error() Ça³ýsocketµÄ´iÎo»oÕß×iºoµÄ´iÎo´uÂe
socket_close() ¹Ø±ÕÒ»¸osocket×ÊÔ´
socket_connect() ¿ªÊ¼Ò»¸osocketÁ¬½Ó
socket_create_listen() ÔÚÖ¸¶¨¶Ë¿Ú´o¿ªÒ»¸osocket¼aÌý
socket_create_pair() ²uÉuÒ»¶ÔûÓÐÇø±ðµÄsocketµ½Ò»¸oÊý×eÀi
socket_create() ²uÉuÒ»¸osocket£¬Ïaµ±ÓÚ²uÉuÒ»¸osocketµÄÊý¾Ý½a¹¹
socket_get_option() »ñÈ¡socketÑ¡Ïi
socket_getpeername() »ñÈ¡Ô¶³ÌÀaËÆÖ÷»uµÄipµØÖ

socket_getsockname() »ñÈ¡±¾µØsocketµÄipµØÖ
socket_iovec_add() Ìi¼ÓÒ»¸oеÄÏoÁ¿µ½Ò»¸o
ÖÉ¢/¾ÛºÏµÄÊý×e
socket_iovec_alloc() Õa¸oº¯Êý´´½¨Ò»¸oÄܹ»¢ËͽÓÊÕ¶ÁдµÄiovecÊý¾Ý½a¹¹
socket_iovec_delete() ɾ³ýÒ»¸oÒѾ­
ÖÅaµÄiovec
socket_iovec_fetch() µ»ØÖ¸¶¨µÄiovec×ÊÔ´µÄÊý¾Ý
socket_iovec_free() ÊÍ
ÅÒ»¸oiovec×ÊÔ´
socket_iovec_set() ÉeÖÃiovecµÄÊý¾ÝÐÂÖµ
socket_last_error() »ñÈ¡µ±Ç°socketµÄ×iºo´iÎo´uÂe
socket_listen() ¼aÌýÓÉÖ¸¶¨socketµÄËuÓÐÁ¬½Ó
socket_read() ¶ÁÈ¡Ö¸¶¨³¤¶ÈµÄÊý¾Ý
socket_readv() ¶ÁÈ¡´ÓÖÉ¢/¾ÛºÏÊý×e¹ýÀ´µÄÊý¾Ý
socket_recv() ´ÓsocketÀi½aÊøÊý¾Ýµ½»º´ae
socket_recvfrom() ½ÓÊÜÊý¾Ý´ÓÖ¸¶¨µÄsocket£¬Èç¹uûÓÐÖ¸¶¨ÔoĬÈϵ±Ç°socket
socket_recvmsg() ´ÓiovecÀi½ÓÊÜÏuÏ¢
socket_select() ¶aÂ
Ñ¡Ôñ
socket_send() Õa¸oº¯Êý¢ËÍÊý¾Ýµ½ÒÑÁ¬½ÓµÄsocket
socket_sendmsg()
¢ËÍÏuÏ¢µ½socket
socket_sendto() ¢ËÍÏuÏ¢µ½Ö¸¶¨µØÖµÄsocket
socket_set_block() ÔÚsocketÀiÉeÖÃΪ¿eģʽ
socket_set_nonblock() socketÀiÉeÖÃΪǿeģʽ
socket_set_option() ÉeÖÃsocketÑ¡Ïi
socket_shutdown() Õa¸oº¯ÊýÔÊÐiÄa¹Ø±Õ¶Á¡¢Ð´¡¢»oÕßÖ¸¶¨µÄsocket
socket_strerror()
µ»ØÖ¸¶¨´iÎoºÅµÄÏeϸ´iÎo
socket_write() дÊý¾Ýµ½socket»º´ae
socket_writev() дÊý¾Ýµ½*ÖÉ¢/¾ÛºÏÊý×e

°¸ÀýÒ»£ºsocketͨÐÅÑÝʾ

*þÎñÆ÷¶Ë£º


     1 <?php 2 //È*±£ÔÚÁ¬½Ó¿Í»§¶Ëʱ²»»a³¬Ê± 3 set_time_limit(0); 4 5 $ip = '127.0.0.1'; 6 $port = 1935; 7 8 /* 9 +------------------------------- 10 *  @socketͨÐÅÕu¸o¹ý³Ì 11 +------------------------------- 12 *  @socket_create 13 *  @socket_bind 14 *  @socket_listen 15 *  @socket_accept 16 *  @socket_read 17 *  @socket_write 18 *  @socket_close 19 +-------------------------------- 20 */ 21 22 /*----------------  ÒÔϲÙ×÷¶¼ÊÇÊÖ²aÉ쵀  -------------------*/ 23 if(($sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0) { 24 echo "socket_create() ʧ°ÜµÄÔ­ÒoÊÇ:".socket_strerror($sock)."\n"; 25 } 26 27 if(($ret = socket_bind($sock,$ip,$port)) < 0) { 28 echo "socket_bind() ʧ°ÜµÄÔ­ÒoÊÇ:".socket_strerror($ret)."\n"; 29 } 30 31 if(($ret = socket_listen($sock,4)) < 0) { 32 echo "socket_listen() ʧ°ÜµÄÔ­ÒoÊÇ:".socket_strerror($ret)."\n"; 33 } 34 35 $count = 0; 36 37 do { 38 if (($msgsock = socket_accept($sock)) < 0) { 39 echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . "\n"; 40 break; 41 } else { 42 43 //*¢µ½¿Í»§¶Ë 44 $msg ="²aÊԳɹ¦£¡\n"; 45 socket_write($msgsock, $msg, strlen($msg)); 46 47 echo "²aÊԳɹ¦ÁË°¡\n"; 48 $buf = socket_read($msgsock,8192); 49 50 51 $talkback = "ÊÕµ½µÄÐÅÏ¢:$buf\n"; 52 echo $talkback; 53 54 if(++$count >= 5){ 55 break; 56 }; 57 58 59 } 60 //echo $buf; 61 socket_close($msgsock); 62 63 } while (true); 64 65 socket_close($sock); 66 ?>

ÕaÊÇsocketµÄþÎñ¶Ë´uÂe¡£È»ºoÔËÐÐcmd£¬×¢ÒaÊÇ×Ô¼ºµÄ³ÌÐo´aeÅÂ*¾¶°¡¡£

ûÓдӳ£¬¶ÔÏÖÔÚþÎñ¶ËµÄ³ÌÐoÒѾ­¿ªÊ¼ÔËÐУ¬¶Ë¿ÚÒѾ­¿ªÊ¼¼aÌýÁË¡£ÔËÐÐnetstat -ano¿ÉÒÔ²e¿´¶Ë¿ÚÇe¿o£¬ÎÒµÄÊÇ1935¶Ë¿Ú

¿´£¬¶Ë¿ÚÒѾ­´¦ÓÚLISTENING״̬ÁË¡£½ÓÏÂÀ´ÎÒÃÇÖ»ÒªÔËÐпͻ§¶Ë³ÌÐo¼´¿ÉÁ¬½ÓÉÏ¡£ÉÏ´uÂe


     1 <?php 2 error_reporting(E_ALL); 3 set_time_limit(0); 4 echo "<h2>TCP/IP Connection</h2>\n"; 5 6 $port = 1935; 7 $ip = "127.0.0.1"; 8 9 /* 10 +------------------------------- 11 *  @socketÁ¬½ÓÕu¸o¹ý³Ì 12 +------------------------------- 13 *  @socket_create 14 *  @socket_connect 15 *  @socket_write 16 *  @socket_read 17 *  @socket_close 18 +-------------------------------- 19 */ 20 21 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 22 if ($socket < 0) { 23 echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n"; 24 }else { 25 echo "OK.\n"; 26 } 27 28 echo "ÊÔͼÁ¬½Ó '$ip' ¶Ë¿Ú '$port'...\n"; 29 $result = socket_connect($socket, $ip, $port); 30 if ($result < 0) { 31 echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n"; 32 }else { 33 echo "Á¬½ÓOK\n"; 34 } 35 36 $in = "Ho\r\n"; 37 $in .= "first blood\r\n"; 38 $out = ''; 39 40 if(!socket_write($socket, $in, strlen($in))) { 41 echo "socket_write() failed: reason: " . socket_strerror($socket) . "\n"; 42 }else { 43 echo "*¢Ë͵½*þÎñÆ÷ÐÅÏ¢³É¹¦£¡\n"; 44 echo "*¢Ë͵ÄÄÚÈÝΪ:<font color='red'>$in</font> <br>"; 45 } 46 47 while($out = socket_read($socket, 8192)) { 48 echo "½ÓÊÕ*þÎñÆ÷»Ø´«ÐÅÏ¢³É¹¦£¡\n"; 49 echo "½ÓÊܵÄÄÚÈÝΪ:",$out; 50 } 51 52 53 echo "¹Ø±ÕSOCKET...\n"; 54 socket_close($socket); 55 echo "¹Ø±ÕOK\n"; 56 ?>

ÖÁ´Ë¿Í»§¶ËÒѾ­Á¬½ÓÉÏ*þÎñ¶ËÁË¡£

°¸Àý¶þ£º´uÂeÏe½a


    // ÉeÖÃÒ»Ð(C)»u±¾µÄ±aÁ¿
    $host = "192.168.1.99";
    $port = 1234;
    // ÉeÖó¬Ê±Ê±¼a
    set_time_limit(0);
    // ´´½¨Ò»¸oSocket
    $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not createsocket\n");
    //°o¶¨Socketµ½¶Ë¿Ú
    $result = socket_bind($socket, $host, $port) or die("Could not bind tosocket\n");
    // ¿ªÊ¼¼aÌýÁ´½Ó
    $result = socket_listen($socket, 3) or die("Could not set up socketlistener\n");
    // accept incoming connections
    // ÁiÒ»¸oSocketÀ´´¦ÀiͨÐÅ
    $spawn = socket_accept($socket) or die("Could not accept incomingconnection\n");
    // »ñµÃ¿Í»§¶ËµÄÊaÈe
    $input = socket_read($spawn, 1024) or die("Could not read input\n");
    // Ça¿ÕÊaÈe×Ö*u´®
    $input = trim($input);
    //´¦Ài¿Í»§¶ËÊaÈe²¢*µ»Ø½a¹u
    $output = strrev($input) . "\n";
    socket_write($spawn, $output, strlen ($output)) or die("Could not write
    output\n");
    // ¹Ø±Õsockets
    socket_close($spawn);
    socket_close($socket);

ÏÂÃaeÊÇÆaÿһ²½ÖeµÄÏeϸ˵Ã÷:

1.µÚÒ»²½Êǽ¨Á¢Á½¸o±aÁ¿À´±£´aeSocketÔËÐеÄþÎñÆ÷µÄIPµØֺͶ˿Ú.Äa¿ÉÒÔÉeÖÃΪÄa×Ô¼ºµÄ*þÎñÆ÷ºÍ¶Ë¿Ú(Õa¸o¶Ë¿Ú¿ÉÒÔÊÇ1µ½65535Ö®¼aµÄÊý×Ö),Ç°ÌaÊÇÕa¸o¶Ë¿Úδ±»Ê¹ÓÃ.

[Copy to clipboard]
PHP CODE:


    // ÉeÖÃÁ½¸o±aÁ¿
    $host = "192.168.1.99" ;
    $port = 1234 ; 

2.ÔÚþÎñÆ÷¶Ë¿ÉÒÔʹÓÃset_time_out()º¯ÊýÀ´È±£PHPÔڵȴý¿Í»§¶ËÁ¬½Óʱ²»»a³¬Ê±.

[Copy to clipboard]
PHP CODE:


    // ³¬Ê±Ê±¼a
    set_time_limit ( 0 ); 

3.ÔÚÇ°ÃaeµÄ»u´¡ÉÏ,ÏÖÔÚ¸ÃʹÓÃsocket_creat()º¯Êý´´½¨Ò»¸oSocketÁË¡ªÕa¸oº¯Êý*µ»ØÒ»¸oSocket¾a±u,Õa¸o¾a±u½«ÓÃÔÚÒÔºoËuÓеĺ¯ÊýÖÐ.

[Copy to clipboard]
PHP CODE:


    // ´´½¨Socket
    $socket = socket_create ( AF_INET , SOCK_STREAM , 0 ) or die( "Could not create
    socket\n" ); 

µÚÒ»¸o²ÎÊý¡±AF_INET¡±ÓÃÀ´Ö¸¶¨ÓoÃu;
µÚ¶þ¸o²ÎÊý¡±SOCK_STREM¡±¸aeËߺ¯Êý½«´´½¨Ò»¸oʲôÀaÐ͵ÄSocket(ÔÚÕa¸oÀý×ÓÖÐÊÇTCPÀaÐÍ)

Òo´Ë,Èç¹uÄaÏe´´½¨Ò»¸oUDP SocketµÄ»°,Äa¿ÉÒÔʹÓÃÈçϵĴuÂe:

[Copy to clipboard]
PHP CODE:


    // ´´½¨ socket
    $socket = socket_create ( AF_INET , SOCK_DGRAM , 0 ) or die( "Could not create
    socket\n" ); 

4.Ò»µ(C)´´½¨ÁËÒ»¸oSocket¾a±u,ÏÂÒ»²½¾ÍÊÇÖ¸¶¨»oÕß°o¶¨Ëuµ½Ö¸¶¨µÄµØÖ*ºÍ¶Ë¿Ú.Õa¿ÉÒÔͨ¹ýsocket_bind()º¯ÊýÀ´Íe³É.

[Copy to clipboard]
PHP CODE:


    // °o¶¨ socket to Ö¸¶¨µØÖ*ºÍ¶Ë¿Ú
    $result = socket_bind ( $socket , $host , $port ) or die( "Could not bind to
    socket\n" ); 

5.µ±Socket±»´´½¨ºÃ²¢°o¶¨µ½Ò»¸o¶Ë¿Úºo,¾Í¿ÉÒÔ¿ªÊ¼¼aÌýÍa²¿µÄÁ¬½ÓÁË.PHPÔÊÐiÄaÓÉsocket_listen()º¯ÊýÀ´¿ªÊ¼Ò»¸o¼aÌý,ͬʱÄa¿ÉÒÔÖ¸¶¨Ò»¸oÊý×Ö(ÔÚÕa¸oÀý×ÓÖоÍÊǵڶþ¸o²ÎÊý:3)

[Copy to clipboard]
PHP CODE:


    // ¿ªÊ¼¼aÌýÁ¬½Ó
    $result = socket_listen ( $socket , 3 ) or die( "Could not set up socket
    listener\n" ); 

6.µ½ÏÖÔÚ,ÄaµÄþÎñÆ÷³ýÁ˵ȴýÀ´×Ô¿Í»§¶ËµÄÁ¬½ÓÇeÇoÍa»u±¾ÉÏʲôҲûÓÐ×o.Ò»µ(C)Ò»¸o¿Í»§¶ËµÄÁ¬½Ó±»ÊÕµ½,socket_accept()º¯Êý±a¿ªÊ¼Æð×÷ÓÃÁË,Ëu½ÓÊÕÁ¬½ÓÇeÇo²¢µ÷ÓÃÁiÒ»¸o×ÓSocketÀ´´¦Ài¿Í»§¶Ë¨CþÎñÆ÷¼aµÄÐÅÏ¢.

[Copy to clipboard]
PHP CODE:


    //½ÓÊÜÇeÇoÁ´½Ó
    // µ÷ÓÃ×Ósocket ´¦ÀiÐÅÏ¢
    $spawn = socket_accept ( $socket ) or die( "Could not accept incoming
    connection\n" ); 

Õa¸o×ÓsocketÏÖÔھͿÉÒÔ±»ËaeºoµÄ¿Í»§¶Ë¨C*þÎñÆ÷ͨÐÅËuÓÃÁË.

7.µ±Ò»¸oÁ¬½Ó±»½¨Á¢ºo,þÎñÆ÷¾Í»aµÈ´ý¿Í»§¶Ë¢ËÍÒ»Ð(C)ÊaÈeÐÅÏ¢,ÕaдÐÅÏ¢¿ÉÒÔÓÉsocket_read()º¯ÊýÀ´»ñµÃ,²¢°ÑËu¸³Öµ¸øPHPµÄ$input±aÁ¿.

[Copy to clipboard]
PHP CODE:


    // ¶ÁÈ¡¿Í»§¶ËÊaÈe
    $input = socket_read ( $spawn , 1024 ) or die( "Could not read input\n" );
    ?& gt ; 

socker_readµÄµÚ¶ø¸o²ÎÊýÓÃÒÔÖ¸¶¨¶ÁÈeµÄ×Ö½ÚÊý,Äa¿ÉÒÔͨ¹ýËuÀ´ÏÞÖÆ´Ó¿Í»§¶Ë»ñÈ¡Êý¾ÝµÄ´oС.

×¢Òa:socket_readº¯Êý»aÒ»Ö±¶ÁÈ¡¿Ç»§¶ËÊý¾Ý,Ö±µ½Óo¼u\n,\t»oÕß\0×Öu.PHP½Å±¾°ÑÕaд×Öu¿´×oÊÇÊaÈeµÄ½aÊø*u.

8.ÏÖÔÚþÎñÆ÷±ØÐe´¦ÀiÕaÐ(C)ÓÉ¿Í»§¶Ë¢À´ÊÇÊý¾Ý(ÔÚÕa¸oÀý×ÓÖеĴ¦Ài½o½o°uº¬Êý¾ÝµÄÊaÈeºÍ»Ø´«µ½¿Í»§¶Ë).Õa²¿Ö¿ÉÒÔÓÉsocket_write()º¯ÊýÀ´Íe³É(ʹµÃÓÉͨÐÅsocket¢»ØÒ»¸oÊý¾ÝÁ÷µ½¿Í»§¶Ë³ÉΪ¿ÉÄÜ)

[Copy to clipboard]
PHP CODE:


    // ´¦Ài¿Í»§¶ËÊaÈe²¢*µ»ØÊý¾Ý
    $output = strrev ( $input ) . "\n" ;
    socket_write ( $spawn , $output , strlen ( $output )) or die( "Could not write
    output\n" ); 

9.Ò»µ(C)Êa³o±»*µ»Øµ½¿Í»§¶Ë,¸¸/×Ósocket¶¼Ó¦Í¨¹ýsocket_close()º¯ÊýÀ´ÖÕÖ¹

[Copy to clipboard]
PHP CODE:


    // ¹Ø±Õ sockets
    socket_close ( $spawn );
    socket_close ( $socket ); 

ÒÔÉϾÍÊÇphpµÄsocketͨÐŵݸÀýÏe½a£¬Ï£Íu¶Ô´o¼Ò½øÒ»²½Ñ§Ï°socketͨÐÅ֪ʶÓÐËu°iÖu¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例