Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux—selectÏê½â

linux—selectÏê½â
selectϵͳµ÷ÓÃʱÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±úµÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐÒ»¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£
¹ØÓÚÎļþ¾ä±ú£¬Æäʵ¾ÍÊÇÒ»¸öÕûÊý£¬Í¨¹ý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¡£
¼ÌÐøÉÏÃæµÄ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ÊÇÓÃÀ´±£´æÕâÑùµÄ¾ä±úµÄ:µ±¾ä±úµÄ״̬±ä³É¿É¶Áʱϵͳ¾Í¸æËßselectº¯Êý·µ»Ø£¬Í¬ÀíµÚ¶þ¸öº¯ÊýÊÇÖ¸ÏòÓоä±ú״̬±ä³É¿Éдʱϵͳ¾Í»á¸æËßselectº¯Êý·µ»Ø£¬Í¬ÀíµÚÈý¸ö²ÎÊýexfdsÊÇÌØÊâÇé¿ö£¬¼´¾ä±úÉÏÓÐÌØÊâÇé¿ö·¢Éúʱϵͳ»á¸æËßselectº¯Êý·µ»Ø¡£ÌØÊâÇé¿ö±ÈÈç¶Ô·½Í¨¹ýÒ»¸ösocket¾ä±ú·¢À´Á˽ô¼±Êý¾Ý¡£Èç¹ûÎÒÃdzÌÐòÀïÖ»Ïë¼ì²âij¸ösocketÊÇ·ñÓÐÊý¾Ý¿É¶Á£¬ÎÒÃÇ¿ÉÒÔÕâÑù£º
fd_set  rdfds;
struct timeval tv;
int ret;
FD_ZERO(&rdfds);
FD_SET(socket, &rdfds);
tv.tv_sec = 1;
tv.tv_uses = 500;
ret = select (socket + 1, %rdfds, NULL, NULL, &tv);
if(ret < 0) perror (“select”);
else if (ret = = 0) printf(“time out”);
else {
       printf(“ret = %d\n”,ret);
       if(FD_ISSET(socket, &rdfds)){
   


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

linuxÔÚÏßÀ©Õ¹Îļþϵͳ¿Õ¼ä

author£ºskate
time£º2009/12/04
 linuxÔÚÏßÀ©Õ¹Îļþϵͳ¿Õ¼ä
ext2resizeÊÇÒ»¿î¿ÉÒÔÔö´ó/¼õСext2/ext3ÎļþϵͳµÄ¹¤¾ß,°²×°ºóÓÐ2¸öÃüÁîext2resizeºÍext2online£¬ext2resizeÃüÁî
±ØÐëÒªÔÚжÔØÎļþϵͳµÄÇé¿öϲÅÄÜʹÓã¬ext2online¿ÉÒÔʵÏÖÔÚÏßÖØÉèÎļþϵͳ´óС¡£
ÏÂÃæ¾ÍÑÝʾ¾ßÌåµÄ²Ù×÷£¬ÕâÊÇÎÒÃÇÑз¢ÓõIJâÊÔ·þÎñ ......

linuxĿ¼˵Ã÷

linuxĿ¼˵Ã÷
¡¡
/bin
ÕâÊÇ·ÅÀýÈ磺 ls, mv, rm, mkdir, rmdir, gzip, tar, telnet, ¼° ftp µÈµÈ³£ÓÃ
µÄÖ´ÐеµµÄµØ·½£¨ÕâЩִÐеµµÄÖ´Ðз½·¨»áÔÚºóÃæÌáµ½£©£¬ÓÐʱºòÕâ¸öĿ¼µÄÄÚÈÝ
Óë /usr/bin ÊÇÒ»ÑùµÄ£¨ÓÐʱºòÉõÖÁ»áʹÓÃÁ¬½áµµÁ¨£©£¬ÊǸøÒ»°ãʹÓÃÕßʹÓõÄÖ´
ÐгÌÐò·ÅÖõÄËùÔÚ£¡
/boot
û´í£¬ÕâÀï¾ÍÊÇ·ÅÖÃÄã Linu ......

linuxÐźŻúÖÆ


linuxÐźŻúÖÆ
 
 
ÐźÅÌṩÁËÒ»ÖÖ֪ͨ½ø³Ìϵͳʼþ·¢ÉúµÄ»úÖÆ£¬ËüÒ²ÊÇ×÷ΪÓû§½ø³ÌÖ®¼äͨÐźÍͬ²½µÄ
Ò»ÖÖԭʼ»úÖÆ¡£ÔÚ½ø³ÌǨÒƵÄÇé¿öÏ£¬ÈçºÎ´¦ÀíÐźÅÄØ£¿Õⲿ·Ö½éÉÜÁËMOSIXϵͳ¶ÔÐźÅ
»úÖƵĴ¦Àí¡£
LINUXÐźŻúÖÆ
ÐźÅÊÇÒì²½µÄ½ø³Ì¼äͨѶ»úÖÆ,ÊÇÔÚÈí¼þ²ã´ÎÉ϶ÔÖжϻúÖƵÄÒ»ÖÖÄ£Äâ¡£LINUXÄں˵ÄÐÅ
ºÅ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ