Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UDP packets greater than 510 bytes clipped




On Jun 21, 2005, at 2:02 AM, Heath Raftery wrote:

I'm using the socket, bind and sendto calls to establish and send UDP data, and NSFileHandle's readInBackgroundAndNotify to read. Would I be right in discovering readToEndOfFileInBackgroundAndNotify does not apply to UDP?



NSFileHandle is not really designed for datagram-oriented protocols.  I would suggest using CFSocket instead, if you wish to receive notifications of data on your run loop.  

Something like

    CFSocketRef s = CFSocketCreateWithNative(NULL, sock, kCFSocketDataCallBack, dataArrived, NULL);
    CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, s, 0);
    CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);

where sock is your UDP socket and

void dataArrived(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) {
    // this is your callback, data is a CFDataRef containing your data
}

Douglas Davidson

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden

References: 
 >UDP packets greater than 510 bytes clipped (From: Heath Raftery <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.