Re: PPP_EVENT
Re: PPP_EVENT
- Subject: Re: PPP_EVENT
- From: Guy Meyer <email@hidden>
- Date: Thu, 16 Jun 2005 23:56:33 +0300
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:
This email sent to email@hidden