I have a working server/client app using Distributed Objects in objective-c. What I am struggling with right now is making the app multi-threaded. So that more users can access the server at the same time.
Here is main function for the server. This is where I create the nsconnection object.
From my understanding, the way I should approach this is when a user tries to access the server, a new thread should be allocated for that particular call. Should the [conn runInNewThread] takes care of this ?
Any thoughts is appreciated...
Here is the code for the server.
int main (void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Transactions *trans = [Transactions new];
NSConnection *conn = [NSConnection defaultConnection];
[conn setRootObject: trans];
[conn runInNewThread];
if (![conn registerName:@"holycow"])
{
NSLog (@"Failed registering holycow.");
exit (1);
}
NSLog (@"waiting for connections...");
[[NSRunLoop currentRunLoop] run];
[pool release];
return 0;
}