Question

I'm absolute beginner to socket programming and i need to work with UDP packets in my application. I'm going to CocoaAsyncSocket library as it's famous for its good qualities. There is a documentation which seems to be helpful for that library but unfortunately it describes AsyncSocket only which deals with TCP and tells nothing about AsyncUdpSocket. So my questions are:

1)Maybe the creators of the library haven't described AsyncUdpSocket cause it's pretty much similar to AsyncSocket? Maybe i should study AsyncSocket and it will give me a lot of understanding of AsyncUdpSocket? I need to know cause i just can't find any tutorials about AsyncUdpSocket. What do you think?

2)If my assumption is correct and it would be helpful for me to studu AsyncUdpSocket via learning AsyncSocket then can you tell me how different they are? What is the difference between them? I think it would be helpful for me to know some things in advance.

Thanks

Was it helpful?

Solution

The same docs can be used for AsyncUdpSocket - just replace AsyncSocket with AsyncUdpSocket. The difference between TCP and UDP is that TCP is connection based, and has a much larger header for the payload data. It requires that the peer send back a message received packet to continue sending payload data. UDP is a faster protocol, per-se, because it ignores all that, and sends payload data as fast as possible with a streamlined header.

tl;dr? AsyncUdpSocket is used the same way as AsyncSocket. TCP is slower, assures data arrival, UDP is faster, data corruption may be possible.

If I recall, the github source provides examples for both UDP and TCP. Take a look at the EchoServer and EchoClient based on UDP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top