How to use CFStream with RakNet on an iPhone?
Asked Answered
M

0

8

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);
 }
Mawson answered 22/11, 2011 at 21:44 Comment(4)
Can you start the connection using CFStream, then use a combination of dup2 to duplicate the file descriptor returned by kCFStreamPropertySocketNativeHandle, and then send that to RakNet to use as its connection?Tennilletennis
@RichardJ.RossIII Maybe raknet.com/forum/index.php?topic=2669.0Sidonie
If more bounty is needed, that can be arranged through another question.Sidonie
Someone please at least give a basic answer otherwise the bounty will go to waste :(Sidonie

© 2022 - 2024 — McMap. All rights reserved.