I'm trying to upload videos to a server via TCP/IP using GCDAsyncSocket
. Sometimes, the socket disconnects with an error that I haven't been able to eliminate:
2011-12-17 11:39:25.073 Hadza[433:707] socketDidDisconnect, error: Error Domain=NSPOSIXErrorDomain Code=12 "Cannot allocate memory" UserInfo=0x2aa260 {NSLocalizedFailureReason=Error in write() function, NSLocalizedDescription=Cannot allocate memory}
I've been looking everywhere but I can't really see what is the cause of this, how to fix it or workaround this issue.
The flow that the app follows to upload a file is the following:
- Write to server (a media_id )
- Read an ACK sign from server
- Read number of bytes already sent
- Write the video from bytes sent to the end
- Read waiting for an ACK signal (meaning that the upload was ok)
- If everything went OK , finish. If there was an error, restart from 1 or 3 depending on the error.