iphone - How to transfer files using socket programming in iOS? -


i worked on sending text messages 1 device device using socket programming in ios.

i successful in doing that, transfer files 1 device device using socket programming, have no tutorial follow. i'm stuck.

please me in resolving it.

thanks in advance.

nsdata *newdata = uiimagepngrepresentation([uiimage imagenamed:@"default.png"]);     int index = 0;     int totallen = [newdata length];     uint8_t buffer[1024];     uint8_t *readbytes = (uint8_t *)[newdata bytes];      while (index < totallen) {         if ([outputstream hasspaceavailable]) {             int indexlen =  (1024>(totallen-index))?(totallen-index):1024;              (void)memcpy(buffer, readbytes, indexlen);              int written = [outputstream write:buffer maxlength:indexlen];              if (written < 0) {                 break;             }              index += written;              readbytes += written;         }     } 

if nsdata big enough need cut pieces.you'll need bytes transfer them.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -