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

Linux System ProgrammingÔĶÁ±Ê¼ÇÖ® read(....)

¹ØÓÚread(...)·µ»ØÖµµÄÕýÈ·Åжϣºp30
File I/O µÄ read(...)º¯ÊýÓ÷¨£º
ÓÐÎÊÌâµÄ´úÂ룬ֻÅжϷµ»ØֵΪ-1µÄÇé¿ö¡£
unsigned long word;
ssize_t nr;
/* read a couple bytes into 'word' from 'fd' */
nr = read (fd, &word, sizeof (unsigned long));
if (nr == -1)
/* error */
Indeed, a call to read( ) can result in many possibilities:
• The call returns a value equal to len. All len read bytes are stored in buf. The
results are as intended.
• The call returns a value less than len, but greater than zero. The read bytes are
stored in buf. This can occur because a signal interrupted the read midway, an
error occurred in the middle of the read, more than zero, but less than len bytes’
worth of data was available, or EOF was reached before len bytes were read.
Reissuing the read (with correspondingly updated buf and len values) will read the
remaining bytes into the rest of the buffer, or indicate the cause of the problem.
• The call returns 0. This indicates EOF. There is nothing to read.
• The call blocks because no data is currently available. This won’t happen in nonblocking
mode.
• The call returns -1, and errno is set to EINTR. This indicates that a signal was
received before any bytes were read. The call can be reissued.
• The call returns -1, and errno is set to EAGAIN. This indicates that the read would
block because no data is currently available, and that the request should be reissued
later. This happens only in nonblocking mode.
• The call returns -1, and errno is set to a value other than EINTR or EAGAIN. This
indicates a more serious error.
ÕýÈ·×ö·¨£º
ssize_t ret;
while (len != 0 && (ret = read (fd, buf, len)) != 0) {
  if (ret == -1) {
    if (errno == EINTR)
    continue;
    perror ("read");
    break;
  }
  len -= ret;
  buf += ret;
}


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

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

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

linux¿éÉ豸·ÖÎöÓëʹÓÃ(תµÄ)


linux¿éÉ豸·ÖÎöÓëʹÓÃ
 
 
linux¿éÉ豸·ÖÎöÓëʹÓÃ
creator
sz111@126.com
 
   ±¾ÆªÎÄÕÂÁ¦Çó¼òµ¥Ã÷Á˵ĽâÊÍLinuxµÄ¿éÉ豸Çý¶¯£¬Èôó¼Ò¶ÔËüÉÙЩη¾å£¬¿ìËٵĿª·¢Ò»¸ö¿éÉ豸¡£·ÖÎöÍêÕâƪ֮ºó£¬ÏÂÒ»²½¾ÍÊÇ·ÖÎöMMC¿¨µÄÇý¶¯£¬ÕùÈ¡·ÖÎöÖ®ºó¿ÉÒÔ´ïµ½ÓÅ»¯¶Á¿¨ËٶȵÄÄ¿µÄ¡£LinuxµÄ¿éÉ豸¿´Ë ......

Linux³ÌÐòÉè¼Æ——ÓÃgetopt´¦ÀíÃüÁîÐвÎÊý

LinuxϺܶà³ÌÐòÉõÖÁÄÇЩ¾ßÓÐͼÐÎÓû§½çÃ棨graphical user interface£¬GUI£©µÄ³ÌÐò£¬¶¼ÄܽÓÊܺʹ¦ÀíÃüÁîÐÐÑ¡Ïî¡£¶ÔÓÚijЩ³ÌÐò£¬ÕâÊÇÓëÓû§½øÐн»»¥µÄÖ÷ÒªÊֶΡ£¾ßÓпɿ¿µÄ¸´ÔÓÃüÁîÐвÎÊý´¦Àí»úÖÆ£¬»áʹµÃÄúµÄÓ¦ÓóÌÐò¸üºÃ¡¢¸üÓÐÓá£getopt()ÊÇÒ»¸öרÃÅÉè¼ÆÀ´¼õÇáÃüÁîÐд¦Àí¸ºµ£µÄ¿âº¯Êý¡£
1¡¢ÃüÁîÐвÎÊý
ÃüÁîÐгÌÐòÉè¼Æ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ