I'm trying to create a TCP server for iPhone. I am following an example Journal of the iPhone to help "SimpleNetworkStream". At compile time I get an error "error: 'Ac开发者_JS百科ceptCallback' undeclared (first use in this function). Could someone help me understand why all of this. The statement seems identical to that made by the example Journal. Thanks
self.listeningSocket = CFSocketCreateWithNative(
NULL,
fd,
kCFSocketAcceptCallBack,
AcceptCallback,
&context
);
static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
//code
}
Add a forward declaration.
static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info);
...
self.listeningSocket = CFSocketCreateWithNative( ... );
...
static void AcceptCallback(...) {
...
Or just put the whole definition of AcceptCallback
before that assignment.
精彩评论