Q: I have a client application which is connecting to a server on another machine. When I specify the hostname, the client successfully connects to the server. The problem occurs when I specify the "*" wild card as thehostname parameter to connectToName: onHost:fromZone:. In this instance the connection fails and nil is returned. What might cause this?
A: When you explicitly specify the hostname, the Distributed Object (DO) request is efficiently routed using the usual TCP/IP routing mechanism to make the connection. However, when you use a wild card search for the host, each machine on the subnet must be queried. For this reason the wild card search limits itself to the immediate subnet. In other words, the wild card search fails if the two machines are not on the same subnet; the two nmserver processes are unable to find each other.
Also see the documentation for +connectToName:onHost:fromZone:.
There are two possible strategies you can employ to avoid using the wild card when you don't know the hostname:
1) Hard code a machine name. Of course, it would be a friendly gesture to allow this machine name to be changed in the Preferences panel of the Client application.
2) Register the name with NetInfo. For example, you might want to create a new directory in the locations directory called myAppNameServer. The myAppNameServer directory would contain a property which lists the value of the hostname where the server is located.