Squeak Class Documentation category index | class index  
 
NetNameResolver
  category: Network-Kernel
  superclass: Object
  subclasses:

This class implements TCP/IP style network name lookup and translation facilities.

Attempt to keep track of whether there is a network available.
HaveNetwork true if last attempt to contact the network was successful.
LastContact Time of that contact (totalSeconds).
haveNetwork returns true, false, or #expired. True means there was contact in the last 30 minutes. False means contact failed or was false last time we asked. Get out of false state by making contact with a server in some way (FileList or updates).

instance methods
  no messages
 

class methods
  address string utils
  addressFromString:
stringFromAddress:

  class initialization
  initialize

  lookups
  addressForName:
addressForName:timeout:
localAddressString
localHostAddress
nameForAddress:timeout:
promptUserForHostAddress
promptUserForHostAddressDefault:
resolverError
resolverStatus

  network initialization
  haveNetwork
haveNetwork:
initializeNetworkIfFail:
primInitializeNetwork:

  primitives
  primAbortLookup
primAddressLookupResult
primLocalAddress
primNameLookupResult
primNameResolverError
primNameResolverStatus
primStartLookupOfAddress:
primStartLookupOfName:

  private
  readDecimalByteFrom:
resolverMutex
waitForCompletionUntil:
waitForResolverReadyUntil:

instance methods
  no messages top  

class methods
  address string utils top  
 

addressFromString:

Return the internet address represented by the given string. The string should contain four positive decimal integers delimited by periods, commas, or spaces, where each integer represents one address byte. Return nil if the string is not a host address in an acceptable format.


 

stringFromAddress:

Return a string representing the given host address as four decimal bytes delimited with decimal points.


  class initialization top  
 

initialize

NetNameResolver initialize


  lookups top  
 

addressForName:


 

addressForName:timeout:

Look up the given host name and return its address. Return nil if the address is not found in the given number of seconds.


 

localAddressString

Return a string representing the local host address as four decimal bytes delimited with decimal points.


 

localHostAddress

Return the local address of this host.


 

nameForAddress:timeout:

Look up the given host address and return its name. Return nil if the lookup fails or is not completed in the given number of seconds. Depends on the given host address being known to the gateway, which may not be the case for dynamically allocated addresses.


 

promptUserForHostAddress

Ask the user for a host name and return its address.


 

promptUserForHostAddressDefault:

Ask the user for a host name and return its address. If the default name is the empty string, use the last host name as the default.


 

resolverError


 

resolverStatus


  network initialization top  
 

haveNetwork

Our best estimate of whether a network is available. Caller will want to ask user if we should try this time.


 

haveNetwork:

Allow user to say we don't want to try to start a connection. Not enforced. Only for caller's information when he asks.


 

initializeNetworkIfFail:

Initialize the network drivers and record the semaphore to be used by the resolver. Do nothing if the network is already initialized. Evaluate the given block if network initialization fails.


 

primInitializeNetwork:

Initialize the network drivers on platforms that need it, such as the Macintosh, and return nil if network initialization failed or the reciever if it succeeds. Since mobile computers may not always be connected to a network, this method should NOT be called automatically at startup time; rather, it should be called when first starting a networking application. It is a noop if the network driver has already been initialized. If non-zero, resolverSemaIndex is the index of a VM semaphore to be associated with the network name resolver. This semaphore will be signalled when the resolver status changes, such as when a name lookup query is completed.


  primitives top  
 

primAbortLookup

Abort the current lookup operation, freeing the name resolver for the next query.


 

primAddressLookupResult

Return the host name found by the last host address lookup. Returns nil if the last lookup was unsuccessful.


 

primLocalAddress

Return the local address of this host.


 

primNameLookupResult

Return the host address found by the last host name lookup. Returns nil if the last lookup was unsuccessful.


 

primNameResolverError

Return an integer reflecting the error status of the last network name resolver request. Zero means no error.


 

primNameResolverStatus

Return an integer reflecting the status of the network name resolver. For a list of possible values, see the comment in the 'initialize' method of this class.


 

primStartLookupOfAddress:

Look up the given host address in the Domain Name Server to find its name. This call is asynchronous. To get the results, wait for it to complete or time out and then use primAddressLookupResult.


 

primStartLookupOfName:

Look up the given host name in the Domain Name Server to find its address. This call is asynchronous. To get the results, wait for it to complete or time out and then use primNameLookupResult.


  private top  
 

readDecimalByteFrom:

Read a positive, decimal integer from the given stream. Stop when a non-digit or end-of-stream is encountered. Return nil if stream is not positioned at a decimal digit or if the integer value read exceeds 255.
JMM - 000503 fixed didn't work correctly


 

resolverMutex


 

waitForCompletionUntil:

Wait up to the given number of seconds for the resolver to be ready to accept a new request. Return true if the resolver is ready, false if the network is not initialized or the resolver does not become free within the given time period.


 

waitForResolverReadyUntil:

Wait up to the given number of seconds for the resolver to be ready to accept a new request. Return true if the resolver is not busy, false if the network is not initialized or the resolver does not become free within the given time period.