views:

67

answers:

1

Hello, 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: 'AcceptCallback' 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
    }
A: 

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.

KennyTM