Receive All Packets ( Opposite of SendAll from Beej tutorials )
- From: Sonny <smaniaol@xxxxxxxxx>
- Date: Thu, 27 Sep 2007 04:11:32 -0700
Hi
Is there a code snippet for receiving packets completely. I mean
during transactions there is a possibility that you won't send or
receive the packets completely. In Beej's tutorials, he has the
SendAll for ensuring that you send the packets.
int sendall(int const s, char const *const buf, int *const len)
{
int total = 0; /* how many bytes we've sent */
int bytesleft = *len; /* how many we have left to send */
int n;
while(total < *len) {
n = send(s, buf+total, bytesleft, 0);
if (n == -1) { break; }
total += n;
bytesleft -= n;
}
*len = total; /* return number actually sent here */
return n==-1?-1:0; /* return -1 on failure, 0 on success */
}
Is there a similar function for receiving all? The tutorial mention
some tips but its very vague for a beginner like me. A terminator
comma( ; ) signals that the transaction is complete. From my
understanding, I can also receive something like this 11;2 , a
packet from the next send can be also fetch if i use just the inverse
of sendall. Would anyone give a sample? I am googling it but can't
find the similar problem. I'm already in panic mode, I need the code
ASAP. The problem arises because I'm connecting to another program
made by others in another language. They don't check if they correctly
send all the packets (does not have something like sendall), I am the
one the must give in (because of seniority). Thanks in advance!
.
- Prev by Date: Re: beating VPN with a VM
- Next by Date: PROTOCOL sending layer 2 packets.. from a os other than linux.. !!!
- Previous by thread: about align pragma
- Next by thread: PROTOCOL sending layer 2 packets.. from a os other than linux.. !!!
- Index(es):
Relevant Pages
|