php fsockopen ÖжàÏ̵߳Ľâ¾ö°ì·¨(2)
ÎÒ ÃÇÓÃstream_select()µÈ´ýsockets´ò¿ªµÄÁ¬½Óʼþ¡£stream_select()µ÷ÓÃϵͳµÄselect(2)º¯ÊýÀ´¹¤ ×÷£ºÇ°ÃæÈý¸ö²ÎÊýÊÇÄãҪʹÓõÄstreamsµÄÊý×飻Äã¿ÉÒÔ¶ÔÆä¶ÁÈ¡£¬Ð´ÈëºÍ»ñÈ¡Òì³££¨·Ö±ðÕë¶ÔÈý¸ö²ÎÊý£©¡£stream_select()¿ÉÒÔͨ¹ýÉè ÖÃ$timeout£¨Ã룩²ÎÊýÀ´µÈ´ýʼþ·¢Éú-ʼþ·¢Éúʱ£¬ÏàÓ¦µÄsocketsÊý¾Ý½«Ð´ÈëÄã´«ÈëµÄ²ÎÊý¡£
Ï ÃæÊÇPHP4.1.0Ö®ºó°æ±¾µÄʵÏÖ£¬Èç¹ûÄãÒѾÔÚ±àÒëPHPʱ°üº¬ÁËsockets(ext/sockets)Ö§³Ö£¬Äã¿ÉÒÔʹÓøùÉÏÃæÀàËƵĴú Â룬ֻÊÇÐèÒª½«ÉÏÃæµÄstreams/filesystemº¯ÊýµÄ¹¦ÄÜÓÃext/socketsº¯ÊýʵÏÖ¡£Ö÷ÒªµÄ²»Í¬ÔÚÓÚÎÒÃÇÓÃÏÂÃæµÄº¯Êý´úÌæ stream_socket_client()À´½¨Á¢Á¬½Ó£º
<?php // This value is correct for Linux, other systems have other values define('EINPROGRESS', 115); function non_blocking_connect($host, $port, &$errno, &$errstr, $timeout) { $ip = gethostbyname($host); $s = socket_create(AF_INET, SOCK_STREAM, 0); if (socket_set_nonblock($s)) { $r = @socket_connect($s, $ip, $port); if ($r || socket_last_error() == EINPROGRESS) { $errno = EINPROGRESS; return $s; } } $errno = socket_last_error($s); $errstr = socket_strerror($errno); socket_close($s); return false; } ?>
ÏÖÔÚÓÃsocket_select()Ìæ»»µôstream_select()£¬ÓÃsocket_read()Ìæ»»µôfread()£¬Óà socket_write()Ìæ»»µôfwrite()£¬ÓÃsocket_close()Ìæ»»µôfclose()¾Í¿ÉÒÔÖ´Ðнű¾ÁË£¡
PHP5µÄÏȽøÖ®´¦ÔÚÓÚ£¬Äã¿ÉÒÔÓÃstream_select()´¦Àí¼¸ºõËùÓеÄstream-ÀýÈçÄã¿ÉÒÔͨ¹ýinclude STDINÓÃËü½ÓÊÕ¼üÅÌÊäÈë²¢±£´æ½øÊý×飬Ä㻹¿ÉÒÔ½ÓÊÕͨ¹ýproc_open()´ò¿ªµÄ¹ÜµÀÖеÄÊý¾Ý¡£
Èç ¹ûÄãÏëÈÃPHP4.3.x×ÔÉíÓµÓд¦ÀístreamsµÄ¹¦ÄÜ£¬ÎÒÒѾΪÄã×¼±¸ÁËÒ»¸öÈÃfsockopen¿ÉÒÔÒì²½¹¤×÷µÄpatch¡£²»ÔÞ³ÉʹÓøò¹¶¡£¬ ¸Ã²¹¶¡²»»á³öÏÖÔÚ¹Ù·½·¢²¼µÄPHP°æ±¾ÖУ¬ÎÒÔÚ²¹¶¡Öи½´øÁËstream_socket_client()º¯ÊýµÄʵÏÖ£¬Í¨¹ýËü£¬Äã¿ÉÒÔÈÃÄãµÄ½Å±¾¼æÈÝ PHP5¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ