• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: BSD socket accept() fd leak on iphone OS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BSD socket accept() fd leak on iphone OS


  • Subject: Re: BSD socket accept() fd leak on iphone OS
  • From: Quinn <email@hidden>
  • Date: Fri, 25 Sep 2009 11:11:59 +0100

Title: Re: BSD socket accept() fd leak on iphone OS
At 12:56 -0700 24/9/09, Jay Bone wrote:
Hopefully this is the right mailing list. lists.apple.com didn't have an iphone networking list.

Feel free to post iPhone OS questions here.  The core networking code is the same on each platform, so there's no reason not to cover both on one mailing list.

One day I'll get around to dealing with the administrivia required to change the list name (-:

I'm trying to write a simple "Hello World" type web server using BSD sockets. When I compile and run this code on a linux box it behaves as I expect, close()'ed file descriptors  originally returned from accept() calls are re-used on subsequent connections.

When I run this same code on an iPhone, close()'ed fd's are not reused and accept() calls continue to return higher and higher fd's until it reaches around 256 and at that point the application locks up.

Is the following code not correct? What am I missing?  (Some error handling omitted)

That's weird.  I can't see anything in your code that would cause this problem.  What does it do on the simulator?  [If you get the same problem on the simulator you can apply better tools to debug it, namely <x-man-page://8/lsof> and <x-man-page://1/dtrace>.]

btw I'm confused by the following:

    if( shutdown(connected, SHUT_RDWR) == -1 ) {
        // Error
    }
   
    // Read rest of packets...
    while(1)
    {
        int bytes = recv( connected, recv_data, BUFF_SIZE, 0 );
        [...]
    }

Given that you've shut down the socket for both read and write, the recv is guaranteed to fail, right?

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >BSD socket accept() fd leak on iphone OS (From: Jay Bone <email@hidden>)

  • Prev by Date: Re: NSURLConnection inserting Accept-Language and Accept headers
  • Next by Date: Re: BSD socket accept() fd leak on iphone OS
  • Previous by thread: BSD socket accept() fd leak on iphone OS
  • Next by thread: Re: BSD socket accept() fd leak on iphone OS
  • Index(es):
    • Date
    • Thread