How to use CFStream with RakNet on an iPhone?

446 views Asked by At

I'm trying to create an iPhone app that will run in the background and uses Raknet transfer data between a client and a server. I followed a tutorial to get a simple chat client and server running.

I want the app to be notified of incoming data when running in the background, but it looks like I have to use CFStreams for the data instead of the sockets that RakNet creates. Is there a way to do this?

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    mRakPeer  = RakPeerInterface::GetInstance();
    mClientID = UNASSIGNED_SYSTEM_ADDRESS;

    SocketDescriptor socketDescriptor(54001,0);
    socketDescriptor.socketFamily=AF_INET;

    mRakPeer->Startup(8,&socketDescriptor, 1);
    mRakPeer->SetOccasionalPing(true);  

    ConnectionAttemptResult car = mRakPeer->Connect("192.168.1.3", 54000, "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"));

    RakAssert(car==RakNet::CONNECTION_ATTEMPT_STARTED);
 }
0

There are 0 answers