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;
?>
-----------
Ïà¹ØÎĵµ£º
ÔÎÄÄÚÈÝûÓб仯£¬ÔÚ¹«Ë¾¿ìÏû»¯ÁËÁ½¸öϵͳÁË£¬ËùÒÔ´òËã×Ô¼ºÐ´Ò»¸ö¹¦ÄÜ»¹¿ÉÒԵĸöÈËϵͳ£¬ÎÒÖªµÀÍøÉϺܶ࣬ÎÒÒ²ÊÕ¼¯Á˺ü¸¸ö£¬µ«ÊÇÏë¿´¿´×Ô¼ºÄܲ»ÄÜ×ö³öÀ´£¬ºÃºÃ¼ÓÓÍ°É£¬ÔڳﱸµÄ¹ý³ÌÖÐÓöµ½ÁËÓʼþÕâÑùµÄÎÊÌ⣬ËùÒÔ»¨Á˵ãʱ¼äÑо¿ÁËÒ»·¬£¬ÍøÉÏÕÒµ½µÄºÃÄÚÈÝ£¬ÄóöÀ´·ÖÏíÒ»ÏÂ
ÒýÓÃÍøÖ·£ºhttp://www.china-askpro.com/msg36/qa ......
´óÈýÏÂѧÆÚ£¬ÎÒ½Ó´¥µ½ÁËPHP£¬Ñ§ÁËÒ»µã»ù±¾µÄÓï·¨£¬ÒòΪ¸úCµÄÓï·¨ºÜÏñ£¬ËùÒÔѧÆðÀ´ºÜÊ¡Á¦¡£½¥½¥µØÎÒϲ»¶ÉÏÁËPHPÕâÃÅÓïÑÔ£¬ÒòΪÓÃËü¿ÉÒÔ×öÍøÕ¾£¬µ½ÁË´óËÄÎÒ±ã¸ü¼ÓÉîÈëµØѧPHPÁË£¬Ñ§Ï°ÓÃPHP×ö¶«Î÷³ÉÁËÎÒÉú»îÖеÄÒ»²¿·Ö...............
PHPÊÇÔËÐÐÓÚ·þÎñÆ ......
ͻȻÏëÆðÁËÔÚÒ»´ÎÃæÊÔµÄʱºòÒªÎÒд³öδÀ´Ò»ÌìÊÇÐÇÆÚ¼¸£¬µ±Ê±Ã»Óиøд³öÀ´¡£ÏÖÔÚÏëÏ뻹ÊǾõµÃ¶ÔdateºÍmktimeµÄ¸ÅÄîºÜÄ£ºý£¬ÔÚÕâÀï¼Ç¼ÏÂÒÔ±¸ºóÓ㺳ÌÐòÈçÏÂ
<?php
echo date( "l dS 0f F Y h£ºi£ºs A" );
echo "<br>";
print("July 1, 2010 is on a " . date("l", mktime(0,0,0,7,11,2010)));
?>
Êä³ö½á¹û ......
ÏÂÃæÊÇÓÃ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) //·µ» ......