Linux select()Ïê½â
Linux select()Ïê½â selectϵͳµ÷ÓÃÊÇÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±ú(file descriptor)µÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐijһ¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£ ÎļþÔÚ¾ä±úÔÚLinuxÀïºÜ¶à£¬Èç¹ûÄãmanij¸öº¯Êý£¬ÔÚº¯Êý·µ»ØÖµ²¿·Ö˵µ½³É¹¦ºóÓÐÒ»¸öÎļþ¾ä±ú±»´´½¨µÄ¶¼Êǵģ¬Èçman socket¿ÉÒÔ¿´µ½“On success, a file descriptor for the new socket is returned.”¶øman 2 open¿ÉÒÔ¿´µ½“open() and creat() return the new file descriptor”£¬ÆäʵÎļþ¾ä±ú¾ÍÊÇÒ»¸öÕûÊý£¬¿´socketº¯ÊýµÄÉùÃ÷¾ÍÃ÷°×ÁË£º int socket(int domain, int type, int protocol); µ±È»£¬ÎÒÃÇ×îÊìϤµÄ¾ä±úÊÇ0¡¢1¡¢2Èý¸ö£¬0ÊDZê×¼ÊäÈ룬1ÊDZê×¼Êä³ö£¬2ÊDZê×¼´íÎóÊä³ö¡£0¡¢1¡¢2ÊÇÕûÊý±íʾµÄ£¬¶ÔÓ¦µÄFILE *½á¹¹µÄ±íʾ¾ÍÊÇstdin¡¢stdout¡¢stderr£¬0¾ÍÊÇstdin£¬1¾ÍÊÇstdout£¬2¾ÍÊÇstderr¡£±ÈÈçÏÂÃæÕâÁ½¶Î´úÂ붼ÊÇ´Ó±ê×¼ÊäÈë¶ÁÈë9¸ö×Ö½Ú×Ö·û£º #include #include #include int main(int argc, char ** argv) { char buf[10] = ""; read(0, buf, 9); /* ´Ó±ê×¼ÊäÈë 0 ¶ÁÈë×Ö·û */ fprintf(stdout, "%s\n", buf); /* Ïò±ê×¼Êä³ö stdout д×Ö·û */ return 0; } /* **ÉÏÃæºÍÏÂÃæµÄ´úÂ붼¿ÉÒÔÓÃÀ´´Ó±ê×¼ÊäÈë¶ÁÓû§ÊäÈëµÄ9¸ö×Ö·û** */ #include #include #include int main(int argc, char ** argv) { char buf[10] = ""; fread(buf, 9, 1, stdin); /* ´Ó±ê×¼ÊäÈë stdin ¶ÁÈë×Ö·û */ write(1, buf, strlen(buf)); return 0; } ¼ÌÐøÉÏÃæ˵µÄselect£¬¾ÍÊÇÓÃÀ´¼àÊÓij¸ö»òijЩ¾ä±úµÄ״̬±ä»¯µÄ¡£selectº¯ÊýÔÐÍÈçÏ£º int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); º¯ÊýµÄ×îºóÒ»¸ö²ÎÊýtimeoutÏÔÈ»ÊÇÒ»¸ö³¬Ê±Ê±¼äÖµ£¬ÆäÀàÐÍÊÇstruct timeval *£¬¼´Ò»¸östruct timeval½á¹¹µÄ±äÁ¿µÄÖ¸Õ룬ËùÒÔÎÒÃÇÔÚ³ÌÐòÀïÒªÉêÃ÷Ò»¸östruct timeval tv;È»ºó°Ñ±äÁ¿tvµÄµØÖ·&tv´«µÝ¸øselectº¯Êý¡£struct timeval½á¹¹ÈçÏ£º struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ }; µÚ2¡¢3¡¢4Èý¸ö²ÎÊýÊÇÒ»ÑùµÄÀàÐÍ£º fd_set *£¬¼´ÎÒÃÇÔÚ³ÌÐòÀïÒªÉêÃ÷¼¸¸öfd_setÀàÐ͵ıäÁ¿£¬±ÈÈçrdfds, wtfds, exfds£¬È»ºó°ÑÕâ¸ö±äÁ¿µÄµØÖ·&rdfds, &wtfds, &exfds ´«µÝ¸øselectº¯Êý¡£ÕâÈý¸ö²ÎÊý¶¼ÊÇÒ»¸ö¾ä±úµÄ¼¯ºÏ£¬µÚÒ»¸ördfdsÊÇÓÃÀ´±£´æÕâÑùµÄ¾ä±úµÄ£ºµ±¾ä±úµÄ״̬±ä³É¿É¶ÁµÄʱϵͳ¾
Ïà¹ØÎĵµ£º
2.1 °²×°JDK
2.1.1 ¼ì²éLinux×Ô´øJDK
ÃüÁrpm –q jdk
Èç¹û°²×°Ç¿ÖÆжÔØ
²é¿´ÒѾ°²×°µÄjdk£º
# rpm -qa|grep jdk ← ²é¿´jdkµÄÐÅÏ¢»òÖ±½ÓÖ´ÐÐ
#rpm -qa|grep ......
ÓÉÓÚwindowsÖÐËùÓÃÍ·Îļþ"windows.h"ÔÚlinuxϲ»¿ÉÓ㬹Ê×Ô¼º½¨Á¢Ïà¹ØµÄÍ·Îļþ£¬¶¨ÒåbmpÎļþµÄ´æ´¢½á¹¹¼°¸ñʽ
´úÂëÈçÏ£º
/* linux_bmp.h*/
/*
* Copyright (c)2010 Chris Grant
*
* Win32 USER structures and API
*/
#include <iostream>
typedef struct ......
Á½¼Ò¼¼ÊõÐÍLinux VPS¹©Ó¦É̵ļ¼ÊõÎĵµ µ±ÎÒÃÇΪÁ˽ÚÔ¼³É±¾¶ø²»µÃ²»Ñ¡ÔñLinux×÷Ϊ·þÎñÆ÷ϵͳ£¬»ù´¡¼¼Êõ¾Í³ÉÁËÎÒÃÇ×î´óµÄÕÏ°£¬³ýÁËÈ¥LinuxµÄÏà¹ØÂÛ̳Í⣬ÕâÀïÍƼöÁ½¼ÒVPSÉ̵ļ¼ÊõÎĵµ£¬ËûÃǵÄVPS¼Û¸ñºÜ¹ó£¬µ«¼¼ÊõºÜºÃ£¬¼¼ÊõÎĵµµÄº¬½ðÁ¿ÉõÖÁ³¬¹ýÁËÄÇЩLinuxÂÛ̳¡£ µÚÒ»¸öÊÇLinodeÎĵµ¿â£¨ÎÒʹÓÃLinode½«½ü1Ä꣬ºÜºÃ£©£º h ......
export£ºÉèÖûòÏÔʾ»·¾³±äÁ¿¡£
Óï¡¡¡¡·¨£ºexport [-fnp][±äÁ¿Ãû³Æ]=[±äÁ¿ÉèÖÃÖµ]
²¹³ä˵Ã÷£ºÔÚshellÖÐÖ´ÐгÌÐòʱ£¬shell»áÌṩһ×é»·¾³±äÁ¿¡£export¿ÉÐÂÔö£¬Ð޸Ļòɾ³ý»·¾³±äÁ¿£¬¹©ºóÐøÖ´ÐеijÌÐòʹÓá£exportµÄЧÁ¦½ö¼°Óڸô˵ǽ²Ù×÷¡£
²Î¡¡¡¡Êý£º
¡¡-f ¡¡´ú±í[±äÁ¿Ãû³Æ]ÖÐΪº¯ÊýÃû³Æ¡£
¡¡-n ¡ ......
1¡£»ñµÃÔ´´úÂë
src ¹ÙÍøÏÂÔصØÖ·£ºftp://ftp.qt.nokia.com/qt/source/
2009 Äê 10 Ô 1 ÈÕ·¢²¼µÄ qt-x11-opensource-src-4.5.3.tar.gz£¬´óС 122 Mb¡£
2¡£½âѹËõ
tar xvfz qt-x11- ......