// JP opened flex table

Click to See Complete Forum and Search --> : Winsock C++ Programming


angwy83
December 10th, 2007, 03:17 AM
Hi, I wanna ask about how I can send more than 1500bytes using UDP sendto() as well as doing it on a non blocking receiving mode.

Heres a an implementation of the send function I have tried but I think its not ideal. How do I fragment data and reassemble them on recv side.

Assume data is a char array of size "data[5000]"


while(total < len) {
n = sendto(sd, data+total, len, 0, (struct sockaddr *)&client, client_length);
if (n == -1){
fprintf(stderr, "Error Sending Datagram.\n");
closesocket(sd);
WSACleanup();
return -1;
break;
}
total += n;
bytesleft -= n;
}
sprintf(msg,"[Sucessfully sent %d bytes of data.]\n [Msg:%s] \n", len, data);
return 0;


Thanks

MikeAThon
December 10th, 2007, 11:48 AM
Why are you trying to fragment? UDP can send up to around 65,000 bytes in one datagram. The IP sub-layer will fragment lagre datagrams for you automatically, and will re-assemble them automatically at the recipient's side.

Of course, the fragmentation and re-assembly process can tend to increase the unreliability of UDP, but since UDP is inherently unreliable anyway, I don't see any benefit in trying to fragment manually at the user level, as opposed to the automatic fragmentaion already provided by UDP.

Mike

.pcbrainbuster
December 11th, 2007, 04:11 PM
Generally its recommended that you work with TCP/IP.

MrViggy
December 11th, 2007, 04:18 PM
Generally, you should start any new concept by getting a good book.

TCP and UDP are part of the transport layer of TCP/IP (http://en.wikipedia.org/wiki/TCP/IP_model).

Viggy

.pcbrainbuster
December 11th, 2007, 04:25 PM
Woops :) - (I will be creating a new thread regaerding this).

//JP added flex table