Re: Registering Clients using DO
Re: Registering Clients using DO
- Subject: Re: Registering Clients using DO
- From: Kiran Kumar S <email@hidden>
- Date: Tue, 5 May 2009 17:46:15 +0530
Creating socket as below in the server side gives the exception. Can
any one guide why this happens so.
int newSocket = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in serverAddress;
int namelen = sizeof(serverAddress);
memset(&serverAddress, 0, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddress.sin_port = htons(8081);
int yes = 1;
setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
bind(newSocket, (struct sockaddr *)&serverAddress, namelen);
listen(newSocket, 128);
NSSocketPort *receivePort = [[NSSocketPort alloc]
initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:0
socket:newSocket];
NSConnection *connection = [NSConnection
connectionWithReceivePort:receivePort sendPort:receivePort];
if i create the port as below then it doesn't gives the exception
NSSocketPort *receivePort;
NSConnection *connection;
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
// Magic fix for socketPort/host leaks!
if ([NSHost respondsToSelector:@selector(_fixNSHostLeak)]) {
[NSHost _fixNSHostLeak];
}
if ([NSSocketPort respondsToSelector:
@selector(_fixNSSocketPortLeak)]) {
[NSSocketPort _fixNSSocketPortLeak];
}
NS_DURING
// This server will wait for requests on port 8081
receivePort = [[NSSocketPort alloc] initWithTCPPort:PORT_NUMBER];
NS_HANDLER
exit(-1);
NS_ENDHANDLER
// Create the connection object
connection = [NSConnection connectionWithReceivePort:receivePort
sendPort:nil];
[receivePort release];
[connection enableMultipleThreads];
[connection setRootObject:[ServerObject sharedServerObject]];
[connection addRunLoop:runloop];
[connection setDelegate:self];
[receivePort release];
Regards
SKiran
On 05-May-09, at 11:10 AM, Kiran Kumar S wrote:
hi ken,
So, the questions are: is -getServer called on the main thread? Is
the client object, the one which you pass to the server with -
registerClient:. retained so that it is still alive when the ping
comes?
the object i send is shared object, which exist until the
application quits.
Regards
SKiran
On 30-Apr-09, at 2:08 PM, Ken Thomases wrote:
On Apr 30, 2009, at 3:06 AM, Kiran Kumar S wrote:
On 30-Apr-09, at 12:03 PM, Ken Thomases wrote:
On Apr 30, 2009, at 12:47 AM, Kiran Kumar S wrote:
I am developing a client/server application using DO. In server
an object is vended to be accessible by clients.In the client
side i am accessing vended object and get required info from
server.Every thing works fine. Until now my client queries
server and server replies to that. But on serverside if any
updates goes, i had to inform client.so i thought of registering
the client and ping the client for updates.So in Client side i
get vended object and registered it to server.When my server
pings the client its giving error *** NSDistantObject
initWithCoder: 0x1 not given away for conn 0xf8937f0
Can you break on this error? On what line of code is it
happening? What's the backtrace?
this exception occurs when server pings,
2009-04-30 13:22:13.835 Project X[7044:10b] *** NSDistantObject
initWithCoder: 0x1 not given away for conn 0x10c17ce0
It looks like the above is separate from the below exception,
although probably related. That message is far from clear. An
Apple engineer may be able to help.
It seems to be saying that it has received an object identifier
(0x1) which doesn't correspond to any object that was sent out on
the connection in question.
2009-04-30 13:22:13.836 Project X[7044:10b] NSExceptionHandler has
recorded the following exception:
NSInternalInconsistencyException -- *** -[NSConcretePortCoder
decodeInvocation]: no local target
Stack trace: 0xb5919a 0x94372e3b 0x95d8aeeb 0x95d8af2a
0x90e847bc 0x90e8425d 0x90e8074c 0x90e8386e 0x90e8358d
0x90e830be 0x90fc4395 0x90fc37ae 0x95d1a87c 0x95d1bf65
0x95d115f5 0x95d11cd8 0x910e9480 0x910e9299 0x910e910d
0x96bff3ed 0x96bfeca0 0x96bf7cdb 0x38de9a 0x96bc4f14 0x37225
0x27a6 0x1
An Project X exception of type NSInternalInconsistencyException
occured.
*** -[NSConcretePortCoder decodeInvocation]: no local target
Stack trace:
1 +[NSException raise:format:arguments:] (in CoreFoundation) +
155
2 +[NSException raise:format:] (in CoreFoundation) + 58
3 -[NSConcretePortCoder decodeInvocation] (in Foundation) + 1068
4 -[NSConcretePortCoder decodeRetainedObject] (in Foundation) +
909
5 _NSWalkData2 (in Foundation) + 1724
6 -[NSConnection handleRequest:sequence:] (in Foundation) + 78
7 -[NSConnection handlePortCoder:] (in Foundation) + 1149
8 -[NSConcretePortCoder dispatch] (in Foundation) + 142
9 -[NSSocketPort _handleMessage:from:socket:] (in Foundation) +
821
10 __NSFireSocketData (in Foundation) + 734
11 __CFSocketDoCallback (in CoreFoundation) + 476
12 __CFSocketPerformV0 (in CoreFoundation) + 133
13 CFRunLoopRunSpecific (in CoreFoundation) + 3141
14 CFRunLoopRunInMode (in CoreFoundation) + 88
15 RunCurrentEventLoopInMode (in HIToolbox) + 283
16 ReceiveNextEventCommon (in HIToolbox) + 374
17 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 106
18 _DPSNextEvent (in AppKit) + 657
19 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 128
20 -[NSApplication run] (in AppKit) + 795
21 -[MainApp run] (in Project X) (MainApp.m:506)
22 NSApplicationMain (in AppKit) + 574
23 main (in Project X) (main.m:28)
2009-04-30 13:22:16.422 Project X[7044:10b] *** -
[NSConcretePortCoder decodeInvocation]: no local target
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden