Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.protocols.tcp-ip    |    TCP and IP network protocols.    |    14,669 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 13,241 of 14,669    |
|    Jorgen Grahn to zhangyefei.yefei@gmail.com    |
|    Re: how to use MSG_PEEK flag    |
|    02 Dec 09 12:41:30    |
   
   185baab0   
   From: grahn+nntp@snipabacken.se   
      
   On Wed, 2009-12-02, zhangyefei.yefei@gmail.com wrote:   
   > hi all,   
   > If i want to read N bytes from a socket ,can i do it like this:   
   > 1) first ,i call recv with MSG_PEE flag to confirm whether having   
   > N bytes available.   
   > repeat it untill having N bytes available.   
   > 2) then, call read once (and just once ) to receive N bytes.   
   >   
   > the following is my codes:   
   > /*   
   > return value:   
   > 0 : got len bytes in buf successfully   
   > -1: error when receiving data from socket   
   > */   
   > int myrcv(int fd,int len,char* buf)   
   > {   
   > int n=0;   
   > //peeking whether having n bytes available   
   > while (n
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca