0

I am trying to write a program that can connect over the network. I have a server and a client, and I would like to send notifications from the server to the clients.

If I use my client to get infos from server, everything work well, but if I try to configure the connection to work both way, I got:

2013-01-17 10:44:04.948 Test Client[11475:405] Distributed objects message send timed out (timeout: 10480150844.948212 at time: 380130944.948432)

This is the code for my server (where server is an instance of a custom object):

NSSocketPort* send = [[NSSocketPort alloc] initWithTCPPort:6139];
//    send=nil;
theConnection = [NSConnection connectionWithReceivePort:[[NSSocketPort alloc] initWithTCPPort:6138] sendPort:send];
[theConnection setRootObject:server];

and for my Client

NSSocketPort* recieve = [[NSSocketPort alloc]
                         initRemoteWithTCPPort:6139 host:@"127.0.0.1"];
//    recieve =nil;

NSConnection *connection = [NSConnection
                            connectionWithReceivePort: recieve sendPort:
         [[NSSocketPort alloc] initRemoteWithTCPPort:6138 host:@"127.0.0.1"]];
theProxy = [connection rootProxy];

If I uncomment the =nil lines, this works, but else I got the error. Does someone know what I am doing wrong?

Thanks in advance.

Have a good day!

impact27
  • 527
  • 4
  • 15
  • You have 2 processes and both try to init the same 2 ports on the same host. Have you tried that on 2 different hosts already? – ott-- Jan 17 '13 at 16:56
  • Yes, I have the same result, it works when i send nil for one of the ports and timeout when I init both. But from the apple doc I should init the same two ports but inversed in role to connect two NSConnection objects. – impact27 Jan 17 '13 at 17:25

0 Answers0