All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class AcmeNet.Assn2.ClientServerNI
AcmeNet.Assn2.ClientServerNI
  -  public class ClientServerNI
 
A network interface that supports client-server communication.
    -  See Also:
    
 -  Service, Connection
 
  
  -  
	ClientServerNI()
   -   Create a ClientServerNI at any available address.
  
 -  
	ClientServerNI(NetAddress)
   -   Create a ClientServerNI at a specified address.
 
  
  -  
	bindService(int, Service)
   -   Bind a service to a local service number.
  
 -  
	connect(ServiceAddress)
   -   Connect to a remote service.
  
 -  
	enable()
   -   The first call to this method "turns on" the processing of incoming packets.
  
 -  
	getAddress()
   -   Get the address of this ClientServerNI
 
  
 -  
	getOutPacketStream(NetAddress)
   -   Get a DataOutputStream that can be used to build a packet that will be sent
 via the underlying ReliableNI.
  
 -  
	run()
   -   Called by a daemon thread.
  
 -  
	sendPing(NetAddress, int)
   -   Send a Ping packet.
  
 -  
	sendPong(NetAddress, int)
   -   Send a Pong packet.
  
 -  
	unbindService(int)
   -   Unbind a service.
 
  
ClientServerNI
 public ClientServerNI()
  -  Create a ClientServerNI at any available address.
 
ClientServerNI
 public ClientServerNI(NetAddress requiredAddress) throws AddressUnavailableException
  -  Create a ClientServerNI at a specified address.
  
    -  Parameters:
    
 -  requiredAddress - the address to use
    
 -  Throws: AddressUnavailableException
    
 -  the requested address was not available
  
 
 
 
  
getAddress
 public NetAddress getAddress()
  -  Get the address of this ClientServerNI
  
    -  Returns:
    
 -  s the address of this ClientServerNI
  
 
 
 
enable
 public synchronized void enable()
  -  The first call to this method "turns on" the processing of incoming packets.
 Before this method is called, all incoming packets are accumulated; when this
 method is called, all accumulated packets are processed.  Subsequent packets are
 processed immediately upon their arrival.
 
 Multiple calls to this method are allowed, but only the first one has any effect.
 
connect
 public Connection connect(ServiceAddress sa) throws IOException
  -  Connect to a remote service.
  
    -  Parameters:
    
 -  sa - the address of the service to connect to
    
 -  Returns:
    
 -  a Connection to the requested service, or null if no connection could be made
    
 -  Throws: IOException
    
 -  some I/O error occurred
  
 
 
 
bindService
 public synchronized void bindService(int serviceNum,
                                      Service service) throws AlreadyBoundException
  -  Bind a service to a local service number.
 This allows remote processes to connect to the service by specifying its NetAddress
 and service number.
  
    -  Parameters:
    
 -  serviceNum - the service number to bind to
    
-  service - the service to bind to that number
    
  -  Throws: AlreadyBoundException
    
 -  some other service is already bound to that serviceNumber
  
 
 
 
unbindService
 public synchronized void unbindService(int serviceNum)
  -  Unbind a service.  If there is no service bound at the requested number, do nothing.
  
    -  Parameters:
    
 -  serviceNum - the service number which should be unbound
  
 
 
 
run
 public void run()
  -  Called by a daemon thread.
 This method is responsible for grabbing incoming packets and doing whatever 
 processing is required.
 
getOutPacketStream
 DataOutputStream getOutPacketStream(NetAddress dest)
  -  Get a DataOutputStream that can be used to build a packet that will be sent
 via the underlying ReliableNI.  This method is for internal use and should not
 be called by clients.
  
    -  Parameters:
    
 -  the - destination of the newly created packet
    
 -  Returns:
    
 -  an output stream that can be used to build the packet
  
 
 
 
sendPing
 void sendPing(NetAddress peerAddr,
               int peerConnNum) throws IOException
  -  Send a Ping packet.
  
    -  Parameters:
    
 -  peerAddr - the address to send the packet to
    
-  peerConnNum - the remote connection number that is being pinged
    
  -  Throws: IOException
    
 -  some I/O error occurred
  
 
 
 
sendPong
 void sendPong(NetAddress peerAddr,
               int peerConnNum) throws IOException
  -  Send a Pong packet.
  
    -  Parameters:
    
 -  peerAddr - the address to send the packet to
    
-  peerConnNum - the remote connection number that is being ponged
    
  -  Throws: IOException
    
 -  some I/O error occurred
  
 
 
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index