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: PPP_EVENT




My application needs to be notified when the PPP-connection is closed (for whatever reason).
ppp_msg.h has some constants that sound like they should do what I want:

(I'm already using ppplib for establishing the connection and closing it)
How should I receive those events?

Hi

The best source for ppp understanding is the darwin source code.

Attached sample code which enables ppp events callback (works on 10.2, 10.3 & 10.4).

If I remember correctly there are two types of events you can register for (look at the ppp source).

Please note there is a bug in Tiger causing PPP_EVT_DISCONNECTED to be sent twice, you should ignore the first one being sent after PPP_EVT_LCP_DOWN.

Guy

int reftoAPIcallback;
CFSocketRef callbackSocketRef;
CFRunLoopSourceRef runLoopSource;
CFSocketContext context = { 0, NULL, NULL, NULL, NULL };

PPPInit(&reftoAPIcallback);
callbackSocketRef = CFSocketCreateWithNative(NULL, reftoAPIcallback, kCFSocketReadCallBack, pppCallBack, &context);
if (callbackSocketRef == 0) {
/// handle error and exit
}
CFSocketSetSocketFlags (callbackSocketRef,CFSocketGetSocketFlags(callbackSocketRef) && !!kCFSocketCloseOnInvalidate);
runLoopSource = CFSocketCreateRunLoopSource(NULL, callbackSocketRef, 0);
if (runLoopSource == 0) {
/// handle error and exit
}
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource,kCFRunLoopDefaultMode);
CFRelease(runLoopSource);



void pppCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
CFSocketNativeHandle socket;
socket=CFSocketGetNative(s);
if (socket==reftoAPIcallback) {
/// get event via calling PPPExec
}
}
 _______________________________________________
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



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.