• <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 閱讀(2381) 評論(0)  編輯 收藏 引用

            久久亚洲天堂| 色综合色天天久久婷婷基地| 亚洲婷婷国产精品电影人久久| 青青久久精品国产免费看| 久久无码中文字幕东京热| 久久精品中文闷骚内射| 欧美精品一区二区久久 | 亚洲AV无码久久| 国产欧美久久久精品| 久久亚洲AV永久无码精品| 99re久久精品国产首页2020| 久久久久久a亚洲欧洲aⅴ| 久久久久香蕉视频| 亚洲国产一成人久久精品| 丁香五月综合久久激情| 久久婷婷五月综合国产尤物app| 高清免费久久午夜精品| 99久久精品免费看国产一区二区三区| 久久国产精品-国产精品| 久久久久久午夜精品| 国产成人精品久久亚洲| 久久精品中文字幕一区| 亚洲午夜精品久久久久久浪潮| 国产偷久久久精品专区 | 久久精品人妻一区二区三区| 久久青青草视频| 国产99久久久久久免费看| 久久久av波多野一区二区| 精品久久久久久久久免费影院| 丰满少妇人妻久久久久久4| 狠狠色丁香婷婷久久综合不卡| 久久久久高潮毛片免费全部播放| 伊人久久亚洲综合影院| 久久精品不卡| 麻豆国内精品久久久久久| 久久一本综合| 日本WV一本一道久久香蕉| 久久久久亚洲精品男人的天堂| 国产呻吟久久久久久久92| 999久久久免费国产精品播放| 久久精品中文字幕久久|