• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
DO timing out on proxy call
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DO timing out on proxy call


  • Subject: DO timing out on proxy call
  • From: Greg Hulands <email@hidden>
  • Date: Fri, 27 Sep 2002 18:06:31 +1000

I have a client and a server that uses NSNetServices to discover each
other. Once they have found each other, i am trying to set up
distributed objects as the communication layer. In the server I set it
up as follows:
- (IBAction)startServer:(id)sender
{
int fdForListening;
struct sockaddr_in serverAddress;

if((fdForListening = socket(AF_INET, SOCK_STREAM, 0)) > 0) {
memset(&serverAddress, 0, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddress.sin_port = htons(port);

while(bind(fdForListening, (struct sockaddr *)&serverAddress,
sizeof(serverAddress)) < 0) {
port++;
serverAddress.sin_port = htons(port);
}
}
if(!netService)
{
netService = [[NSNetService alloc] initWithDomain:@"local.arpa."

type:@"_taserver._tcp."
name:[serverName
stringValue]
port:port];
[netService setDelegate:self];
}
if(netService)
{
[netService publish];
[serverName setEnabled:NO];
}
// Setup DO Connection
doConnection = [[NSConnection alloc]
initWithReceivePort:[[NSSocketPort alloc] initWithTCPPort:port]
sendPort:nil];
[doConnection setRootObject:server];
}

And in the client when a service is selected:
- (void)connectToServer:(NSNetService *)server
{
NSData *address = [[server addresses] objectAtIndex:0];
struct sockaddr_in *socketAddress = (struct sockaddr_in *)[address
bytes];
NSString *strHost;
NSSocketPort *port;

int firstOctet = (socketAddress->sin_addr.s_addr & 0xFF000000) >>
24;
int secondOctet = (socketAddress->sin_addr.s_addr & 0x00FF0000) >>
16;
int thirdOctet = (socketAddress->sin_addr.s_addr & 0x0000FF00) >> 8;
int fourthOctet = (socketAddress->sin_addr.s_addr & 0x000000FF) >>
0;

strHost = [NSString stringWithFormat:@"%d.%d.%d.%d", firstOctet,
secondOctet, thirdOctet, fourthOctet];

port = [[NSSocketPort alloc]
initRemoteWithTCPPort:socketAddress->sin_port host:strHost];
connection = [[NSConnection connectionWithReceivePort:nil
sendPort:port] retain];

_server = [connection rootProxy];
}

On the last line is where the call just times out, and thus does not
get the rootProxy. I have tried restarting the computer, but to no
avail. What would be causing the time out as the server and client are
currently running on the same machine?

Any help is very much appreciated.

Regards,
Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Menu when click on table cell
  • Next by Date: Re: NSUndoManager & NSTableView editing
  • Previous by thread: Unusual error message
  • Next by thread: [NSWindow print:] and button images
  • Index(es):
    • Date
    • Thread