2

I am trying to make a chat application which will use UDP connection.Using GCDAsyncUdpSocket from here i am able to connect and send small text to another device with this function

- (void)sendData:(NSData *)data
      toHost:(NSString *)host
        port:(uint16_t)port
 withTimeout:(NSTimeInterval)timeout
         tag:(long)tag

But for large text it is not working. I have two questions here:

  1. Does GCDAsyncUdpSocket automatically breaks data into small piece of UDP packets and sends them? Or they sends all the data at once?
  2. How to break the whole text in small chunk before sending it using GCDAsyncUdpSocket and keeping track of the chunks? Is there any 3rd party code available for this?
souvickcse
  • 7,742
  • 5
  • 37
  • 64
  • Do you have any constraint to work only on UDP protocol? You can use _GCDAsyncSocket_ which uses TCP protocol and manages the data chunk itself. All you have to do is read the data properly. – Gandalf Mar 02 '15 at 13:31
  • Yes I need UDP, I need to communicate between two device which are under two different nat(for example one is on wifi and another is on 3g). – souvickcse Mar 02 '15 at 15:13
  • No it was working fine with large text. But while sending image error occuring like **Error Domain=GCDAsyncUdpSocketErrorDomain Code=1 "Cannot specify destination of packet for connected socket" UserInfo=0x79158000 {NSLocalizedDescription=** – Karthik Mandava Jul 10 '15 at 11:01
  • Having same issue with image, if found any help please share – Jageen Apr 25 '16 at 13:17
  • I have used breaking the the data into pieces and sending it, and keeping track of the chunks, i haven't found any third party for this, so did it my self – souvickcse Apr 25 '16 at 14:24

0 Answers0