Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6789151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:34:10+00:00 2026-05-26T17:34:10+00:00

I am using distributed object for inter process communication. I am running one server

  • 0

I am using distributed object for inter process communication. I am running one server and four instance of client but i am getting NSPortTimeoutException. I want to store client object @server for further communication between clients.
//client code

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

ClientCode *client = [[ClientCode alloc] init];

/* Get the proxy */
id <myProtocol> proxy = (id <myProtocol>)[NSConnection rootProxyForConnectionWithRegisteredName: @"DirectoryServer" host:nil usingNameServer: [NSSocketPortNameServer sharedInstance]];

if ([proxy conformsToProtocol:@protocol(myProtocol)]) {
    NSLog(@"YES");
}
else {
    NSLog(@"NO");
}

NSString *recDataFromServer = [proxy print: client];
NSLog(@"%@", recDataFromServer);
/* Release the pool */
[pool release]
return 0;
}

@protocol myProtocol
-(NSString *)print : (id)client;
@end
@interface ClientCode : NSObject {


}
@end
@implementation ClientCode

-(void)startClient
{
NSLog(@"server called me");
}
@end

server Code

@interface printHello : NSObject <myProtocol>{
NSMutableArray *saveClassObject;
}
@end

@implementation printHello


- (id) init
{
self = [super init];
if (self != nil) {
    saveClassObject = [[NSMutableArray alloc] init];
}
return self;
}

-(NSString *)print : (bycopy id)client
{   
[saveClassObject addObject: client];
//NSLog(@"%@", NSStringFromClass([client class]));

NSLog(@"client calling.....");
[client startClient];
NSLog(@"%@", saveClassObject);
return @"parag";
}


-(void)recieveMessage
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSThread detachNewThreadSelector:@selector(startObserver) toTarget:self withObject:nil];
[pool release];
}

-(void)startObserver
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

printHello *telephoneDirectory= [[printHello alloc] init];

/*
 * Create a new socket port for your connection.
 */
NSSocketPort *port = [NSSocketPort port];

NSLog(@"%d", [port isValid]);
/*
 * Create a connection using the socket port.
 */
NSConnection *connXion = [NSConnection connectionWithReceivePort: port
                                                        sendPort: port];
/*
 * Set the responding server object as
 * the root object for this connection.
 */
[connXion setRootObject: telephoneDirectory];

/*
 * Try to register a name for the NSConnection,
 * and report an error if this is not possible.
 */
if ([connXion registerName: @"DirectoryServer"
            withNameServer: [NSSocketPortNameServer sharedInstance]] == NO)
{
    NSLog(@"Unable to register as 'DirectoryServer'");
    NSLog(@"Perhaps another copy of this program is running?");
    exit(1);
}

/* Start the current runloop. */
[[NSRunLoop currentRunLoop] run];

[telephoneDirectory release];
/* Release the pool */
[pool release];
return 0;

}

Output @client

2011-10-11 20:50:35.415 client[54606:903] called
2011-10-11 20:50:35.424 client[54606:903] (null)
2011-10-11 20:50:35.420 client[54608:903] called
2011-10-11 20:50:35.425 client[54608:903] (null)
2011-10-11 20:50:35.424 client[54607:903] called
2011-10-11 20:50:35.428 client[54607:903] (null)
2011-10-11 20:50:35.434 client[54609:903] called
2011-10-11 20:50:35.437 client[54609:903] (null)
2011-10-11 20:50:36.091 client[54606:903] YES
2011-10-11 20:50:36.093 client[54609:903] YES
2011-10-11 20:50:36.093 client[54607:903] YES
2011-10-11 20:50:36.094 client[54608:903] YES
2011-10-11 20:50:36.098 client[54606:903] server called me
2011-10-11 20:50:36.103 client[54608:903] server called me
2011-10-11 20:50:36.117 client[54608:903] parag
2011-10-11 20:50:36.119 client[54609:903] server called me
2011-10-11 20:50:36.125 client[54607:903] server called me
2011-10-11 20:50:36.127 client[54606:903] parag
2011-10-11 20:50:36.125 client[54609:903] *** Terminating app due to uncaught exception 'NSPortTimeoutException', reason: '[NOTE: this exception originated in the server.]
[NSPortCoder sendBeforeTime:sendReplyPort:] timed out (10340039236.124821 340039236.124922) 1'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00007fff825487b4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x00007fff84d95f03 objc_exception_throw + 45
    2   Foundation                          0x00007fff86416483 -[NSConnection sendInvocation:internal:] + 4304
    3   CoreFoundation                      0x00007fff8251a98c ___forwarding___ + 860
    4   CoreFoundation                      0x00007fff82516a68 _CF_forwarding_prep_0 + 232
    5   client                              0x0000000100000d4f main + 307
    6   client                              0x0000000100000c14 start + 52
    7   ???                                 0x0000000000000001 0x0 + 1
)

Output @server

2011-10-11 20:50:36.095 DistributedServer[54579:1303] client calling.....
2011-10-11 20:50:36.098 DistributedServer[54579:1303] client calling.....
2011-10-11 20:50:36.100 DistributedServer[54579:1303] client calling.....
2011-10-11 20:50:36.102 DistributedServer[54579:1303] client calling.....
2011-10-11 20:50:36.115 DistributedServer[54579:1303] (
    "<ClientCode: 0x100111250>",
    "<ClientCode: 0x100111250>",
    "<ClientCode: 0x100111250>",
    "<ClientCode: 0x100111250>"
)

When I am running client second time i getting output at client console but i am getting nothing at server console.

client output second time

2011-10-11 20:53:54.514 client[54801:903] called
2011-10-11 20:53:54.518 client[54801:903] (null)
2011-10-11 20:53:54.521 client[54800:903] called
2011-10-11 20:53:54.526 client[54800:903] (null)
2011-10-11 20:53:54.516 client[54804:903] called
2011-10-11 20:53:54.526 client[54804:903] (null)
2011-10-11 20:53:54.529 client[54803:903] called
2011-10-11 20:53:54.533 client[54803:903] (null)
2011-10-11 20:53:54.955 client[54803:903] YES
2011-10-11 20:53:54.956 client[54800:903] YES
2011-10-11 20:53:54.956 client[54801:903] YES
2011-10-11 20:53:54.956 client[54804:903] YES
2011-10-11 20:53:54.961 client[54804:903] server called me
2011-10-11 20:53:54.963 client[54801:903] server called me
2011-10-11 20:53:54.964 client[54801:903] parag
2011-10-11 20:53:54.965 client[54800:903] server called me
2011-10-11 20:53:54.966 client[54800:903] parag
2011-10-11 20:53:54.966 client[54804:903] parag
2011-10-11 20:53:54.969 client[54803:903] server called me
2011-10-11 20:53:54.970 client[54803:903] parag

Any idea on how to fix NSPortTimeoutException?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:34:10+00:00Added an answer on May 26, 2026 at 5:34 pm

    NSPortTimeoutException was coming because i was saving object of client @server and not removing that object after termination of client. Now my code is working fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Distributed Object for client server communication. I am storing clients object
I have client server application using distributed object. some time my code is working
Scenario I've written a distributed application in C# using WCF. It uses Client/Server architecture,
I have client server cocoa application. client communicate with server by using server's IP
I'm in the process of evaluating how to implement something using a distributed key/value
I am using Two SQL Server connection object in my C# console application project.
I'm trying to execute a distributed transaction for a single Oracle linked server using
I'd like to hear from people who are using distributed version control (aka distributed
What are the benefits and drawbacks with using Centralized versus Distributed Version Control Systems
Is using JBoss Cache as distributed state repository a good idea? Can JBoss Cache

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.