Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5984821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:26:08+00:00 2026-05-22T22:26:08+00:00

I’m trying to send a file on FTP server in my iPhone application. Everything

  • 0

I’m trying to send a file on FTP server in my iPhone application.
Everything seems to be okay in WiFi and GSM:EDGE network, but in 3G network an error appears (not always, but very often):

Error Domain=NSPOSIXErrorDomain
Code=12 “The operation couldn’t be
completed. Cannot allocate memory”

Below the code where the error appears:

- (void)stream:(NSStream*)aStream handleEvent:(NSStreamEvent)eventCode {

    switch( eventCode ) {
        case NSStreamEventHasSpaceAvailable: {
            if( _readDataOffset == _readDataLimit ) {
                NSInteger readDataLen = [_readStream read:[_readData mutableBytes] maxLength:kReadDataLength];
                NSLog(@"readDataLen is %d",readDataLen);
                if( -1 == readDataLen ) {
                    _error = [[_readStream streamError] retain];
                    _keepRunning = NO;
                } else if( 0 == readDataLen ) {
                    _keepRunning = NO;
                } else {
                    _readDataOffset = 0;
                    _readDataLimit = readDataLen;
                }
            }

            if( _readDataOffset != _readDataLimit ) {
                NSOutputStream* writeStream = (NSOutputStream*)aStream;

                uint8_t *buffer = (void *)[_readData bytes];

          // vvvv and here  the value of writtenDataLen is often -1 (but only on 3G network)
                NSInteger writtenDataLen = [writeStream write:&buffer[_readDataOffset] maxLength:_readDataLimit - _readDataOffset]; 


                if( writtenDataLen > 0 ) {
                    _readDataOffset += writtenDataLen;
                    _writtenDataLen += writtenDataLen;
                    [self ftpPutDidWriteInternal];
                } else if( -1 == writtenDataLen ) {
                    _error = [[writeStream streamError] retain];
                    _keepRunning = NO;
                }
            }

        } break;
        case NSStreamEventErrorOccurred: {
            _error = [aStream.streamError retain];
            _keepRunning = NO;
        } break;
    }    
}

What can be important, the whole sending is done in separate thread which has it’s own NSAutoreleasePool.
Is there anyone who got the issue? Any suggestion? I would be appreciate.

UPDATE:
I’ve just checked that popular iPhone application “FTP On The Go” has got the same (?) issue during sending a file in 3G network! There is no error handled, but the transfer stops.

UPDATE 2:
I can’t believe it, but it’s true: SimpleFTPSample from Apple is also affected with the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:26:09+00:00Added an answer on May 22, 2026 at 10:26 pm

    And here it is – the solution (or rather workaround):

    you should set property of writeStream to false, to switch off default persistant connection

    CFWriteStreamSetProperty( (CFWriteStreamRef)writeStreamRef, kCFStreamPropertyFTPAttemptPersistentConnection, kCFBooleanFalse ) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.