Networking Forums

Networking Forums > Computer Networking > Linux Networking > Receive All Packets ( Opposite of SendAll from Beej tutorials )

Reply
Thread Tools Display Modes

Receive All Packets ( Opposite of SendAll from Beej tutorials )

 
 
Sonny
Guest
Posts: n/a

 
      09-27-2007, 11:11 AM
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!

 
Reply With Quote
 
 
 
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NICs can't receive inbound packets at boot Electronic Workplace Windows Networking 3 08-13-2007 09:13 PM
recvfrom():how to receive multiple UDP packets. aakashrajvanshi@gmail.com Linux Networking 1 07-31-2006 05:55 PM
send and receive raw packets with PF_PACKET and bypassing the kernel nehavrce@yahoo.co.in Linux Networking 0 01-06-2005 07:37 AM
I can send packets but I receive nothing, routing problem riviereg Linux Networking 8 09-06-2004 12:49 PM
I can send packets but I receive nothing, routing problem riviereg Linux Networking 0 09-03-2004 09:44 AM



1 2 3 4 5 6 7 8 9 10 11