• 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
Re: Distributed Objects and Leopard issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distributed Objects and Leopard issue


  • Subject: Re: Distributed Objects and Leopard issue
  • From: Aurélien Hugelé <email@hidden>
  • Date: Tue, 27 Nov 2007 13:16:08 +0100

receivePort = [[[NSSocketPort alloc] initWithProtocolFamily:PF_INET
socketType:SOCK_STREAM
protocol:0
socket:sockfd] autorelease];

Is incorrect

use

receivePort = [[NSSocketPort alloc] initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:IPPROTO_TCP socket:sockfd];

instead. Note that protocol is not the same :)

This fixed my problems on Leopard... Tiger was much more tolerant to this...


Aurélien, Objective Decision Team




On 27 nov. 07, at 00:26, Allan Dushan wrote:

Does anyone have a workaround for the code below? This code worked great pre-Leopard.

In order to get the server/client to work I had to switch the server code below to the single call:

receivePort = [[NSSocketPort alloc] initWithTCPPort:8000];

This allows the client to connect, but no longer allows me to modify the socket. The important modification is SO_REUSEADDR. Since I cannot do this anymore, if the user quits/force quits the applications, they have to wait 2+ minutes before restarting the application in order for the port to be available again.

Using the current code below, the client can connect, and get the root proxy, but when you try to make a call to the root proxy an exception is thrown.

Is this a bug in Leopard, or do I need to set things up another way with leopard?

One last note, if the client is running on an OS that is pre-Leopard and the server is on Leopard, the connection works. The problem occurs when both are running on Leopard.

Allan



Server side:
----------------

sockfd = socket(AF_INET, SOCK_STREAM, 0);

memset(&serverAddress, 0, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); //need big-endian byte order
serverAddress.sin_port = htons(8000);

fcntl( sockfd, F_SETFD, 1 );
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
timeToWait.tv_sec = 30; // Timeout after n seconds...
timeToWait.tv_usec = 0;
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &timeToWait, sizeof(timeToWait));
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeToWait, sizeof(timeToWait));
bind(sockfd, (struct sockaddr *)&serverAddress, namelen);
listen(sockfd, 10);


receivePort = [[[NSSocketPort alloc] initWithProtocolFamily:PF_INET
socketType:SOCK_STREAM
protocol:0
socket:sockfd] autorelease];


theConnection = [[NSConnection alloc] initWithReceivePort:receivePort sendPort:nil];

[theConnection setRootObject:self];


Client side: ---------------

sendPort = [[[NSSocketPort alloc] initRemoteWithTCPPort:8000 host:hostName] autorelease];
remoteConnection = [[NSConnection alloc] initWithReceivePort:nil sendPort:sendPort];
remoteServerMgr = [remoteConnection rootProxy];
[remoteServerMgr doSomething];
_______________________________________________


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

_______________________________________________

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


  • Follow-Ups:
    • Re: Distributed Objects and Leopard issue
      • From: Allan Dushan <email@hidden>
References: 
 >Distributed Objects and Leopard issue (From: Allan Dushan <email@hidden>)

  • Prev by Date: Re: Setting the bundle bit [Was: Re: UTI's and document packages]
  • Next by Date: Re: Compare image levels?
  • Previous by thread: Distributed Objects and Leopard issue
  • Next by thread: Re: Distributed Objects and Leopard issue
  • Index(es):
    • Date
    • Thread