Re: UDP message boundary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

> On Fri, Oct 19, 2012 at 9:15 PM, Lorenzo Beretta <lory.fulgi@xxxxxxxxxxx> wrote:
> Almost:
> 1. udp is not reliable, so transmission may just fail
> 2. there's a maximum lenght of 64k (16 bit size counter)
> 3. ip fragmentation: as packet size grows, iirc one fragment lost means you
> loose everything

Lorenzo: Yes, I already know what UDP socket is, I'm asking about UDP
message boundary behaviour.






> On 17/10/2012 05:24, Randi Botse wrote:
>>
>> Anyone can share? :)
>>
>> Thanks
>>
>>
>> On Mon, Oct 15, 2012 at 11:50 AM, Randi Botse<nightdecoder@xxxxxxxxx>
>> wrote:
>>>
>>> Hi All
>>>
>>> When using TCP socket, I loop send() or recv() until ALL the data has
>>> been transmitted (or error, disconnect, etc.), because TCP socket
>>> packet is transmitted in stream nature, maybe a byte, bytes or all
>>> bytes in one transfer.
>>>
>>> The UDP socket preserve message boundary which TCP socket doesn't.
>>> Does this means single call to sendto() will processed by single call
>>> recvfrom()?, and how about packet that exceeds UDP data MAX size?.
>>>
>>> So in code, do I need to loop sendto() or recvfrom() to transmit the
>>> data?.
>>>
>>> Example codes is:
>>>
>>> char packet[100];
>>> size_t nbytes = 0;
>>> int ret;
>>>
>>> while (nbytes<  sizeof(packet)) {
>>>      ret = recvfrom(socket, packet + nbytes, addr, 0,  sizeof(packet) -
>>> nbytes);
>>>      if (ret<= 0) {
>>>          /* deal with recvfrom() error */
>>>      }
>>>      nbytes += ret
>>> }
>>>
>>>
>>> Thanks
>>
>> --
>>
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-c-programming" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

>
> You can start from the wikipedia page and explore from that, or read the
> source of any program doing serious stuff with udp(*)
>
>
> (*) there's an ftp alternative called fsp which uses udp, but I can't
> comment on the source code because I've never read it
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux