Linux IO????????ú?????
???????????? ???????[ 2015/7/8 13:34:31 ] ??????????????
????Linux???е?IO?????????read??write??recv??send??recvmsg??sendmsg??readv??writev???????????????????????????
????read??????
????#include <unistd.h>
????ssize_t read(int fd??void *buf??size_t count);
????read???????????????fd?????????У????count????????buf???????????count?0??read?????0?????????????????????count???????SSIZE_MAX???????????????????????????????????λ?????????????λ?????С????????????????
???????read??г?????????????????????????-1???????????д?????????????????????β??????0?????У?ssize??????????????int??long????????????????????????????????int?????????long??
????write??????
????#include <unistd.h>
????ssize_t write(int fd??const void *buf??size_t count);
??????????????read?????
????recv??????
????#include <sys/types.h>
????#include <sys/socket.h>
????ssize_t recv(int s??void *buf??size_t len??int flags);
????recv?????????????????ú??????????s?н???????????????buf?У?buf?????len????????????flags??????????????s??????????????????????????????socket??????????????????buf????????????????????????????????????len????????????С??????????λ???????????flags???????y????????????
????MSG_DONTWAIT??????????????IO??????????????????????????????????????????????IO?????????????????
????MSG_ERRQUEUE???????????????????????Э?顣
????MSG_OOB?????????????????????????????????????????
????MSG_PEEK????????????????????recv??????к?????????Щ?????????
????MSG_TRUNC???????????????????????????С??????????????????????????????????????????????????????С????????????????????????
????MSG_WAITALL?????????????ж????????????????????????????????????????????????????readn()??????????????????
????#define readn(fd??ptr??n) recv(fd??ptr??n??MSG_WAITALL).
?????????????MSG_WAITALL??????????????????a??????????b?????????c??????????????????????????????????????????????
?????????MSG_WAITALL???????????????????????????????????????????е????????????????????????????????????????
????????recv()????????????????????????????????-1?????????
????recv()???????TCP??UDP???recvfrom??????????????????????????????????????????????recv?????????????
????recv()???????????????и?????????????????????????????е????????????????С??????????£???в???MSG_WAITALL???????????????е??????????????????????????????????????????е????????????????????????????????????????????е?????????????????????????????????′ε??y?????????????????????????????????????????????????????????????е?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11