• 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
Connections dropped before accept(2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Connections dropped before accept(2)


  • Subject: Connections dropped before accept(2)
  • From: Eric Hodel <email@hidden>
  • Date: Fri, 25 Jul 2008 11:48:10 -0700

I am writing a UPnP media server in ruby and I am seeing OS X drop sockets before handing them to accept(2). Apple Ruby 1.8.6 on OS X 10.5.4 is the server and is connected to a PlayStation 3 client with a FreeBSD 6 router in between.

The HTTP traffic as seen by the router looks like this (s and d are the source and destination ports, extra header fields trimmed):

s: 58005 d: 61537
GET /MediaServer/ContentDirectory/1/01 Electronic Performers.mp3 HTTP/1.1


s: 61537 d: 58005
HTTP/1.1 200 OK
Date: Fri, 25 Jul 2008 05:22:28 GMT
Content-Length: 13543785

s: 58004 d: 61537
GET /MediaServer/ContentDirectory/1/01 Electronic Performers.mp3 HTTP/1.1
Range: bytes=13543657-13543784


s: 58003 d: 61537
GET /description HTTP/1.1

s: 61537 d: 58003
HTTP/1.1 200 OK
Date: Fri, 25 Jul 2008 05:22:49 GMT

The PS3 doesn't read all the content returned by the first GET, instead it shuts down the connection after it's read several hundred K.

The PS3 makes a second GET immediately after terminating the first GET for the last 127 bytes of the MP3. This GET is never seen by the userland, its socket is not returned by accept. The PS3 indicates that an error happened and that it's unable to play the MP3.

If I understand TCP sockets correctly, the PS3 should not send the text of the GET request until the kernel has accepted the connection, even if the socket hasn't been handed to the user yet.

The third GET happens a little later and is handled fine.

If I run this same code on FreeBSD 7 under parallels with ruby 1.8.6 it works as expected (same hardware, bridged networking). The second GET for 127 bytes is received by the userland and the PS3 plays the MP3.

While trying to figure out what's going on here, I poked around inside ruby's socket library. Ruby calls listen(2) with a backlog of 5. One of my friends suggested adjusting this value and seeing what happens. Since I don't have exactly the apple sources, I compiled ruby 1.8 from subversion and tried it out. With the default listen backlog of 5 I can duplicate this problem. If I change the value to SOMAXCONN (128) everything works like it's supposed to and the PS3 plays the MP3.

I don't know how changing the listen backlog would affect this, the PS3 is the only client for this server and there don't ever appear to be more than one socket waiting for accept, certainly not when I select an MP3 to play. Equally confusing is that FreeBSD works fine with a backlog of 5.

_______________________________________________
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


  • Follow-Ups:
    • Re: Connections dropped before accept(2)
      • From: Segment 7 <email@hidden>
  • Prev by Date: MacNetworkProg Administrivia
  • Next by Date: Re: Connections dropped before accept(2)
  • Previous by thread: MacNetworkProg Administrivia
  • Next by thread: Re: Connections dropped before accept(2)
  • Index(es):
    • Date
    • Thread