Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: OS X Socket Performance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OS X Socket Performance



Paul Ferguson, email@hidden, wrote:
>> Based on some discussion on the Cocoa dev list, there are apparently
>> three options for creating socket based applications on OS X: use an
>> objective-c wrapper around BSD sockets (like SmallSockets), create a
>> BSD socket in straight C, or use CFNetwork.
>>
>> My question is this: which of these options offers the highest
>> performance? My guess is that working in straight C with BSD sockets
>> would be, but I have a strong desire to stick with Apple's APIs in
>> order to leverage any future enhancements to CFNetwork.
>
>If you look at the SmallSockets source code, you'll see that it is a
>very thin wrapper around the BSD socket API, and imposes little or no
>overhead beyond what you would typically do in a Cocoa app anyway (such
>as using NSData objects to manage packet data, using NSException for
>error handling, etc.)

A biggie may be ObjC dynamic method dispatch overhead. Chances are it
won't be a problem, as networks run rather slowly compared processors and
local memory. However, I could easily see it consuming the machine if
you're reading a gigabit stream one byte at a time.

That said, with ObjC it's easy to get a function pointer given a selector
and bypass the overhead, if necessary.

.......................................................
Jonathan 'Wolf' Rentzsch jon at redshed dot net
Red Shed Software http://redshed.net (847) 584-7465
PGP: B2AF 1A09 F881 EBDE C9D6 C4D2 C04F A3C0 3EC5 D5F2

"better" necessarily means "different"
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.