Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

Receive All Packets ( Opposite of SendAll from Beej tutorials )

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2007, 12:11 PM
Default Receive All Packets ( Opposite of SendAll from Beej tutorials )



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!



Sonny
Reply With Quote
Reply

Tags
beej, opposite, packets, receive, sendall, tutorials

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 10:29 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.