php Socket »ù´¡
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-24
tprotobyname()º¯Êý¶øÊÇÖ¸¶¨SOL_TCP»òSOL_UDPÔÚsocket_create()º¯ÊýÖС£ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); Àý×ӵĵڶþÐÐÊDzúÉúÒ»¸ösocket²¢ÇÒ·µ»ØÒ»¸ösocket×ÊÔ´µÄʵÀý¡£ÔÚÄãÓÐÁËÒ»¸ösocket×ÊÔ´µÄʵÀýÒÔºó£¬Äã¾Í±ØÐë°Ñsocket°ó¶¨µ½Ò»¸öIPµØÖ·ºÍijһ¸ö¶Ë¿ÚÉÏ¡£ socket_bind($socket, ¡®localhost¡¯, 1337); ÔÚÕâÀïÄã°ó¶¨socketµ½±¾µØ¼ÆËã»ú£¨127.0.0.1£©ºÍ°ó¶¨socketµ½ÄãµÄ1337¶Ë¿Ú¡£È»ºóÄã¾ÍÐèÒª¼àÌýËùÓнøÀ´µÄsocketÁ¬½Ó¡£ socket_listen($socket); ÔÚµÚËÄÐÐÒÔºó£¬Äã¾ÍÐèÒªÁ˽âËùÓеÄsocketº¯ÊýºÍËûÃǵÄʹÓᣠ±íËÄ£ºSocketº¯Êý º¯ÊýÃû ÃèÊö socket_accept() ½ÓÊÜÒ»¸öSocketÁ¬½Ó socket_bind() °Ñsocket°ó¶¨ÔÚÒ»¸öIPµØÖ·ºÍ¶Ë¿ÚÉÏ socket_clear_error() Çå³ýsocketµÄ´íÎó»òÕß×îºóµÄ´íÎó´úÂë socket_close() ¹Ø±ÕÒ»¸ösocket×ÊÔ´ socket_connect() ¿ªÊ¼Ò»¸ösocketÁ¬½Ó socket_create_listen() ÔÚÖ¸¶¨¶Ë¿Ú´ò¿ªÒ»¸ösocket¼àÌý socket_create_pair() ²úÉúÒ»¶ÔûÓÐÇø±ðµÄsocketµ½Ò»¸öÊý×éÀï socket_create() ²úÉúÒ»¸ösocket£¬Ï൱ÓÚ²úÉúÒ»¸ösocketµÄÊý¾Ý½á¹¹ socket_get_option() »ñÈ¡socketÑ¡Ïî socket_getpeername() »ñÈ¡Ô¶³ÌÀàËÆÖ÷»úµ**pµØÖ· socket_getsockname() »ñÈ¡±¾µØsocketµ**pµØÖ· socket_iovec_add() Ìí¼ÓÒ»¸öеÄÏòÁ¿µ½Ò»¸ö·ÖÉ¢/¾ÛºÏµÄÊý×é socket_iovec_alloc() Õâ¸öº¯Êý´´½¨Ò»¸öÄܹ»·¢ËͽÓÊÕ¶Áдµ**ovecÊý¾Ý½á¹¹ socket_iovec_delete() ɾ³ýÒ»¸öÒѾ·ÖÅäµ**ovec socket_iovec_fetch() ·µ»ØÖ¸¶¨µ**ovec×ÊÔ´µÄÊý¾Ý socket_iovec_free() ÊÍ·ÅÒ»¸öiovec×ÊÔ´ socket_iovec_set() ÉèÖÃiovecµÄÊý¾ÝÐÂÖµ socket_last_error() »ñÈ¡µ±Ç°socketµÄ×îºó´íÎó´úÂë socket_listen() ¼àÌýÓÉÖ¸¶¨socketµÄËùÓÐÁ¬½Ó socket_read() ¶ÁÈ¡Ö¸¶¨³¤¶ÈµÄÊý¾Ý socket_readv() ¶ÁÈ¡´Ó·ÖÉ¢/¾ÛºÏÊý×é¹ýÀ´µÄÊý¾Ý socket_recv() ´ÓsocketÀï½áÊøÊý¾Ýµ½»º´æ socket_recvfrom() ½ÓÊÜÊý¾Ý´ÓÖ¸¶¨µÄsocket£¬Èç¹ûûÓÐÖ¸¶¨ÔòĬÈϵ±Ç°socket socket_recvmsg() ´ÓiovecÀï½ÓÊÜÏûÏ¢ socket_select() ¶à·ѡÔñ socket_send() Õâ¸öº¯Êý·¢ËÍÊý¾Ýµ½ÒÑÁ¬½ÓµÄsocket socket_sendmsg() ·¢ËÍÏûÏ¢µ½socket socket_sendto() ·¢ËÍÏûÏ¢µ½Ö¸¶¨µØÖ·µÄsocket socket_set_block() ÔÚsocketÀïÉèÖÃΪ¿éģʽ socket_set_nonblock() socketÀïÉèÖÃΪ·Ç¿éģʽ socket_set_option() ÉèÖÃsocketÑ¡Ïî socket_shutdown() Õâ¸öº¯ÊýÔÊÐíÄã¹Ø±Õ¶Á¡¢Ð´¡¢»òÕßÖ¸¶¨µÄsocket socket_strerror() ·µ»ØÖ¸¶¨´íÎóºÅµÄÏêϸ´íÎó socket_write() дÊý¾Ýµ½socket»º´æ socket_writev() дÊý¾Ýµ½·ÖÉ¢/¾ÛºÏÊý×é ÒÔÉÏËùÓеĺ¯Êý¶¼ÊÇPHPÖйØÓÚsocketµÄ£¬Ê¹ÓÃÕâЩº¯Êý£¬Äã±ØÐë°ÑÄãµÄsocket´ò¿ª£¬Èç¹ûÄãûÓдò¿ª£¬Çë±à¼ÄãµÄphp.iniÎļþ£¬È¥µôÏÂÃæÕâÐÐÇ°ÃæµÄ×¢ÊÍ£º extension=php_sockets.dll Èç¹ûÄãÎÞ·¨È¥µô×¢ÊÍ£¬ÄÇôÇëʹÓÃÏÂÃæµÄ´úÂëÀ´¼ÓÔØÀ©Õ¹¿â£º <?php if(!extension_loaded(¡®sockets¡¯)) { if(strtoupper(substr(PHP_OS, 3) |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |
Äã¿ÉÄܶÔÏÂÃæµÄÎÄÕ¸ÐÐËȤ
- java¼S?×hÇÔòwindowsºÉÌñÀÇÓÉ×hxCopy - ˆ@š£Ã؉¯Àû
- 15 ·Ç³£ÓÐȤµÄ CSS3 ʾÀý
- PhotoshopºÏ³É½Ì³Ì:ÖÆ×÷±¼³ÛÆû³µÍøÂç¹ã¸æ
- linux ÈíRAIDͼ½â½Ì³Ì
- ÔÚApache GeronimoÖв¿ÊðWeb·þÎñ - ±à³ÌÈëÃÅÍø
- ÍøÂç·Óɼ¼Êõ¼°ÔËÓÃ
- PSÇáËÉÖÆ×÷÷ÈÁ¦ÎÞÏÞµÄË®µ×³¡¾°
- Photoshopµ÷É«½Ì³Ì£º¾ªÑÞÃÀÅ®
- PSÕÕƬµ÷É«½Ì³Ì:Ä£·ÂEEÉ«µ÷·ç¾°ÕÕƬ
- Linux×ÀÃæ°æºáÆÀ£ºËÄ¡¢SuSE Linux Enterprise Desktop 10 SP1
ÉÏһƪ: ³É¹¦°²×°Mysql+Apache2+php5¹ý³ÌÏÂһƪ: ¹ØÓÚPHP½Ó¿ÚµÄѧϰ
¹ØÓÚphp Socket »ù´¡µÄËùÓÐÆÀÂÛ