PHPÖ®Socket±à³Ì
±¾ÆªÎÄÕÂÀ´Ô´ÓÚ ºÚ¿Í»ùµØ-È«Çò×î´óµÄÖÐÎĺڿÍÕ¾ ÔÎÄÁ´½Ó£ºhttp://hackbase.com/tech/2009-08-04/54550_1.html
2007Äê11ÔÂ01ÈÕ ÐÇÆÚËÄ ÏÂÎç 03:48ÈÃÎÒÃÇÒÔÒ»¸ö¼òµ¥µÄÀý×Ó¿ªÊ¼---Ò»¸ö½ÓÊÕÊäÈë×Ö·û´®,´¦Àí²¢·µ»ØÕâ¸ö×Ö·û´®µ½¿Í»§¶ËµÄTCP·þÎñ.ÏÂÃæÊÇÏàÓ¦µÄ´úÂë:PHP ´úÂë: ------------------------------------------------- ...
2007Äê11ÔÂ01ÈÕ ÐÇÆÚËÄ ÏÂÎç 03:48ÈÃÎÒÃÇÒÔÒ»¸ö¼òµ¥µÄÀý×Ó¿ªÊ¼---Ò»¸ö½ÓÊÕÊäÈë×Ö·û´®,´¦Àí²¢·µ»ØÕâ¸ö×Ö·û´®µ½¿Í»§¶ËµÄTCP·þÎñ.ÏÂÃæÊÇÏàÓ¦µÄ´úÂë:
PHP ´úÂë:
--------------------------------------------------------------------------------
<?
// ÉèÖÃһЩ»ù±¾µÄ±äÁ¿
$host = "192.168.1.99";
$port = 1234;
// ÉèÖó¬Ê±Ê±¼ä
set_time_limit(0);
// ´´½¨Ò»¸öSocket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create
socket\n");
//°ó¶¨Socketµ½¶Ë¿Ú
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
// ¿ªÊ¼¼àÌýÁ´½Ó
$result = socket_listen($socket, 3) or die("Could not set up socket
listener\n");
// accept incoming connections
// ÁíÒ»¸öSocketÀ´´¦ÀíͨÐÅ
$spawn = socket_accept($socket) or die("Could not accept incoming
connection\n");
// »ñµÃ¿Í»§¶ËµÄÊäÈë
$input = socket_read($spawn, 1024) or die("Could not read input\n");
// Çå¿ÕÊäÈë×Ö·û´®
$input = trim($input);//½«ÊäÈë½á¹ûдÈëok.php£¬Õâ¾äÊÇÎÒ¼ÓµÄ
fputs(fopen('ok.php','a+'),"$input");
//´¦Àí¿Í»§¶ËÊäÈë²¢·µ»Ø½á¹û
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write
output\n");
// ¹Ø±Õsockets
socket_close($spawn);
socket_close($socket);
?>
--------------------------------------------------------------------------------
ÏÂÃæÊÇÆäÿһ²½ÖèµÄÏêϸ˵Ã÷:
1.µÚÒ»²½Êǽ¨Á¢Á½¸ö±äÁ¿À´±£´æSocketÔËÐеķþÎñÆ÷µÄIPµØÖ·ºÍ¶Ë¿Ú.Äã¿ÉÒÔÉèÖÃΪÄã×Ô¼ºµÄ·þÎñÆ÷ºÍ¶Ë¿Ú(Õâ¸ö¶Ë¿Ú¿ÉÒÔÊÇ1µ½65535Ö®¼äµÄÊý×Ö),ǰÌáÊÇÕâ¸ö¶Ë¿Úδ±»Ê¹ÓÃ.
PHP ´úÂë:
--------------------------------------------------------------------------------
<?
// ÉèÖÃÁ½¸ö±äÁ¿
$host = "192.168.1.99";
$port = 1234;
?>
-----------
Ïà¹ØÎĵµ£º
<?
//ÐÂÎÅÀà±ð
$query_cat="select * from $dbtable1";
$result_cat=mysql_query($query_cat) or die("<mce:script type="text/javascript"><!--
alert('Ìáʾ£º²éѰÐÂÎÅÀà±ðʧ°Ü£¬Çë¸ú¹ÜÀíÔ±ÁªÏµ')
// --></mce:script>");
if(!$resul ......
ÏÂÃæÊÇÓÃ100¸ö²¢·¢Á¬½Ó·Ö±ðȥѹÉú²ú»·¾³ÖÐͬһ¸ºÔؾùºâÆ÷VIPÏ¡¢ÌṩÏàͬ·þÎñµÄÁ½Ì¨·þÎñÆ÷£¬Ò»Ì¨ÎªNginx£¬Áíһ̨ΪApache£¬NginxÿÃë´¦ÀíµÄÇëÇóÊýÊÇApacheµÄÁ½±¶¶à£¬Nginx·þÎñÆ÷µÄϵͳ¸ºÔØ¡¢CPUʹÓÃÂÊÔ¶µÍÓÚApache£º
¡¡¡¡Äã¿ÉÒÔ½«Á¬½ÓÊý¿ªµ½10000¡«30000£¬È¥Ñ¹NginxºÍApacheÉϵÄphpinfo.php£¬ÕâÊÇÓÃä¯ÀÀÆ÷·ÃÎ ......
<?php
/*
*PHP¹ÜÀíMYSQLµÄÊý¾Ý¿âÀà
ʹÓ÷½·¨£º$dbConn = new DbConn([$Êý¾Ý¿âÃû(¿ÉÑ¡)]);
ÔÊÐí·µ»ØµÄ·½·¨£º
Execute($sql) //Ö´ÐÐSQLÓï¾ä£¬Ã»Óзµ»ØÖµ;
getRs($sql) //·µ»Ø²éѯÓï¾äµÄ¼Ç¼£¬Ò»Ìõ;
getRsArray($sql) //·µ» ......
ÖйúµÚÒ»µµÂÌÉ«PHP×ÊÔ´·ÖÏíÃÅ»§,רעÓÚ´´ÐºÍÔ´´ÀàÔ´Âëphp×ÊÔ´£¬Ô´´ÊÓÆµphp×ÊÔ´£¬Ô´´µäÐÍÄ£¿éphp×ÊÔ´£¬Ô´´php¿ªÔ´×ÊÔ´£¬Ô´´php½Ì³Ì×ÊÔ´£¬Ô´´ÍøÕ¾Ä£°å×ÊÔ´ ¡£ÍøÕ¾µØÖ· http://www.phpzy.com/
ÂÌÉ«php×ÊÔ´ ......
1.ðÅÝÅÅÐò
function m_sort($arr)
{
$l = count($arr);
if($l==0) return false;
for($i=0;$i<$l-1;$i++)
{
for($j=$i+1;$j<$l-1;$j++)
......