Class FileServer

java.lang.Object
  extended byjava.util.Observable
      extended byFileServer
All Implemented Interfaces:
Actions, Runnable

public class FileServer
extends Observable
implements Runnable, Actions

This class starts the server and wait for connection

Version:
1.0
Author:
Adeel Hashmi
See Also:
Observable, Runnable

Constructor Summary
FileServer()
           
 
Method Summary
 boolean Alive()
          Check the liveness of Thread all file thread and return status
 String getIP()
          find and return Local IP address of connected server socket return IP Address
 int getPort()
          find and return Local port number of connected server socket return port number
 String getStatus()
          Find and return thread status message
 void run()
          Thread run method
 void setObserver(View v)
          Set the Observer for Observable
protected  void startServer(int port)
          Start file server and thread for accepting connection
protected  void stopServer()
          stop server by closing socket and stopping thread
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileServer

public FileServer()
Method Detail

Alive

public boolean Alive()
Check the liveness of Thread all file thread and return status

Specified by:
Alive in interface Actions
Returns:
true if the threads in a list still alive

getIP

public String getIP()
find and return Local IP address of connected server socket return IP Address

Specified by:
getIP in interface Actions
Returns:
port number

getPort

public int getPort()
find and return Local port number of connected server socket return port number

Specified by:
getPort in interface Actions
Returns:
port number

getStatus

public String getStatus()
Find and return thread status message

Specified by:
getStatus in interface Actions
Returns:
message

run

public void run()
Thread run method

Specified by:
run in interface Runnable
See Also:
Runnable.run()

setObserver

public void setObserver(View v)
Set the Observer for Observable

Specified by:
setObserver in interface Actions
Parameters:
v - Observer Object

startServer

protected void startServer(int port)
                    throws Exception
Start file server and thread for accepting connection

Parameters:
port - port number throws Exception If socket creation unsuccessful
Throws:
Exception

stopServer

protected void stopServer()
stop server by closing socket and stopping thread