• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Bugs

            MMORPG game develop.

            初次使用linux下的異步I/O

             

             1#include <stdio.h>
             2#include <stdlib.h>
             3#include <aio.h>
             4#include <errno.h>
             5
             6
             7int main(int argc, char *argv[])
             8{
             9
            10  int fd, ret;
            11  struct aiocb my_aiocb;
            12
            13  fd = open( "file.txt", O_RDONLY );
            14  if (fd < 0) perror("open");
            15
            16  /* Zero out the aiocb structure (recommended) */
            17  bzero( (char *)&my_aiocb, sizeof(struct aiocb) );
            18
            19  /* Allocate a data buffer for the aiocb request */
            20  my_aiocb.aio_buf = malloc(BUFSIZE+1);
            21  if (!my_aiocb.aio_buf) perror("malloc");
            22
            23  /* Initialize the necessary fields in the aiocb */
            24  my_aiocb.aio_fildes = fd;
            25  my_aiocb.aio_nbytes = BUFSIZE;
            26  my_aiocb.aio_offset = 0;
            27
            28  ret = aio_read( &my_aiocb );
            29  if (ret < 0) perror("aio_read");
            30
            31  while ( aio_error( &my_aiocb ) == EINPROGRESS ) ;
            32
            33  if ((ret = aio_return( &my_iocb )) > 0{
            34      printf("%s\n", my_aiocb.aio_buf);
            35    /* got ret bytes on the read */
            36  }
             else {
            37    /* read failed, consult errno */
            38  }

            39
            40
            41}


            g++ test.cpp -lrt

            posted on 2008-06-19 17:50 Bugs 閱讀(2390) 評論(0)  編輯 收藏 引用

            四虎国产精品免费久久久| 久久人人爽人人人人爽AV| 国内精品久久久久久久久电影网 | 亚洲女久久久噜噜噜熟女| 久久国产精品99国产精| 99久久国产热无码精品免费久久久久 | 久久99热这里只有精品国产| 一级做a爱片久久毛片| 久久国产精品免费一区| 亚洲级αV无码毛片久久精品| 99久久777色| 精品久久久久久无码中文字幕一区| 久久免费视频6| 久久免费精品视频| 一本色综合久久| 久久成人精品| 无码日韩人妻精品久久蜜桃| 精品人妻伦九区久久AAA片69| 亚洲色欲久久久综合网东京热| AA级片免费看视频久久| 99久久99久久精品国产| 午夜精品久久久久久99热| 国产一区二区久久久| 麻豆久久久9性大片| 国产成人99久久亚洲综合精品| 欧美亚洲国产精品久久高清| 91超碰碰碰碰久久久久久综合| 亚洲精品白浆高清久久久久久| 国内精品伊人久久久久妇| 久久久久黑人强伦姧人妻| 久久涩综合| 久久久久久国产精品美女| 久久九九免费高清视频| 精品久久久久久久久久久久久久久| 久久精品国产亚洲AV大全| 老色鬼久久亚洲AV综合| 久久99国产精品久久久| 久久久网中文字幕| 久久人人爽人人精品视频| 久久久久亚洲精品无码网址| 久久人人爽人爽人人爽av |