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;
}
Ïà¹ØÎĵµ£º
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâÆª·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´Ë×ªÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨ÕâÆª²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
ÔÚlinuxÖÐuseridºÍusergroup·Ö±ð´æÓÚ /etc/group, /etc/shadow, /etc/passwd
ÔÚgroup ÖпÉÒÔÐÞ¸Äsudo groupºÍadminȨÏÞ
Ô¶³ÌµÇ½ÉèÖÃÔÚ /etc/ssh/ssh-config ºÍ /etc/ssh/sshd-configÀï£¬ÖØÉèºó /etc/init.d/ssh restart
ÔÚwebminÖиü¸ÄÁËfirewallºó±ØÐëÖØÆôÍøÂç : /etc/init.d/networking restart
In Ubuntu, remote d ......
ÈçºÎÈÃLinux¸ÉµôWindows£¿ÎÒ³ÐÈÏ£¬ÕâÊÇÓеã±êÌâµ³ÁË¡£µ«Õâ¸öÎʺţ¬¹À¼ÆºÜ¶àLinuxµÄ·ÛË¿²»ÖªµÀ»ÃÏë¹ý¶àÉٱ飻ҡÆìÄź°£¬ÁоÙLinuxÖÚ¶àÓŵ㣬ÂÞÁÐWindows¸÷ÖÖ×ïÐУ¬¾ÍÊÇÈÃÈËÃÇÈ¥ÊÔÊÔLinux¡£¿ÉÊǽá¾ÖÔõôÑù£¿´ó¼Ò¶¼¿´µ½ÁË¡£
ΪʲôLinux»áʧ°Ü£¿àÞ£¬²»Ó¦¸Ã˵ÊÇʧ°Ü£¬Ó¦¸ÃÊÇ˵ΪʲôռÓÐÂÊÔ ......