Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

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

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

̤ÉÏLinuxÄÚºËѧϰ֮ÂÃ

³£³£ÓÐÈËÎÊ£ºÎÒÏëѧϰÄںˣ¬ÐèҪʲô»ù´¡Âð£¿Linus Torvalds±¾ÈËÊÇÕâÑù»Ø´ðµÄ£ºÄã±ØÐëʹÓùýLinux¡£ Õâ¸ö……»¹ÊÇÓеãÌ«·ºÁË°É£¬ÎÒÏëÏÂÃ漸¸ö»ù´¡¿ÉÄÜ»¹ÊÇÐèÒªµÄ£¬¾¡¹Ü²»Ò»¶¨±ØÐ裺 
¡¡¡¡1, ¹ØÓÚ²Ù×÷ϵͳÀíÂÛµÄ×î³õ¼¶µÄ֪ʶ¡£²»ÐèҪͨ¶Á²¢Àí½â¡¶²Ù×÷ϵͳ¸ÅÄî¡·¡¶ÏÖ´ú²Ù×÷ϵͳ¡·µÈ¾ÞÖø£¬µ«×ÜÒªÖªµÀ·Öʱ£¨t ......

ShellµÄʹÓ×—linux¹¤³Ìʦ±Øѧ»ù´¡

Ô­µØÖ·£ºhttp://selftest.51cto.com/subread.php?sid=213
×Ô²â¼ò½é£º    
ShellÒ²½Ð×öÃüÁîÐнçÃ棬ËüÊÇUnix/ÀàUnix²Ù×÷ϵͳÏ´«Í³µÄÓû§ºÍ¼ÆËã»úµÄ½»»¥½çÃæ¡£Óû§Ö±½ÓÊäÈëÃüÁîÀ´Ö´Ðи÷ÖÖ¸÷ÑùµÄÈÎÎñ¡£µ±È»Î¢ÈíµÄWindows²Ù×÷ϵͳҲÌṩÁËÕâÑùµÄ¹¦ÄÜ£¬ËüÃÇÊÇWindows 9XϵÄcommand.com£¬ºÍ»ùÓÚWindows NTµÄ¸ ......

ÈçºÎÈÃLinux¸ÉµôWindows£¿

   ÈçºÎÈÃLinux¸ÉµôWindows£¿ÎÒ³ÐÈÏ£¬ÕâÊÇÓеã±êÌâµ³ÁË¡£µ«Õâ¸öÎʺţ¬¹À¼ÆºÜ¶àLinuxµÄ·ÛË¿²»ÖªµÀ»ÃÏë¹ý¶àÉٱ飻ҡÆìÄź°£¬ÁоÙLinuxÖÚ¶àÓŵ㣬ÂÞÁÐWindows¸÷ÖÖ×ïÐУ¬¾ÍÊÇÈÃÈËÃÇÈ¥ÊÔÊÔLinux¡£¿ÉÊǽá¾ÖÔõôÑù£¿´ó¼Ò¶¼¿´µ½ÁË¡£
 
   ΪʲôLinux»áʧ°Ü£¿àÞ£¬²»Ó¦¸Ã˵ÊÇʧ°Ü£¬Ó¦¸ÃÊÇ˵ΪʲôռÓÐÂÊÔ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ