Hey guys, I need help with this client server program I am working on. Description:
The server program takes port # as a command-line argument and performs the following
operations:
1. Opens a socket connection on the specified port
2. Listen for request from clients
3. When a client program sends a request, create a new thread to performs the appropriate
action based on the request
4. Go to step 2
The client program takes the hostname and port # on which the server process is listening as
command-line arguments and performs the following operations:
1. Open a socket connection to connect with the server process
2. Process inputs from the user
3. Send the appropriate command/request to the server process
4. Wait for the server to perform the appropriate action and respond to the client request
5. Process server response if necessary
6. Go to step 2, if the input is “QUIT” then exit.
The various commands that the client and server can process along with the action performed at
the server is given below:
LIST – Send list files in the current directory on the server (initially the directory where the
server program was started would be the current directory)
SIZE filename – Send file size of the specified file name, a negative number if file does not exist
GET filename – Send the specified file to the client process; if the specified file does not exist on
the server then the server send an error message (a negative #); filename is assumed to reside in
the current directory on server and copied to the current directory on the localhost.
PUT filename – Receive the specified file from the client; filename is assumed to be residing in
the current directory on client and is copied to the current directory on the server.
CD newdirectory – change to specified directory on the server; print an error message if the
directory does not exist.
QUIT – client program exists after closing any open connections, no action is performed on the
server.
Assume that the files are in binary format for file transfer.

Server Program:

import java.net.*;
import java.io.*;

public class FileServer {

    static final int LISTENING_PORT = 3210;

    public static void main(String[] args) {

        File directory;             // The directory from which the
                                    // gets the files that it serves.
        ServerSocket listener;         // Listens for connection requests.
        Socket connection;             // A socket for communicating with
                                    // a client.

        /* Check that there is a command-line argument.
         If not, print a usage message and end. */

        if (args.length == 0) {
            System.out.println("Usage:  java FileServer <directory>");
            return;
        }

        /* Get the directory name from the command line, and make
         it into a file object.  Check that the file exists and
         is in fact a directory. */

        directory = new File(args[0]);
        if (!directory.exists()) {
            System.out.println("Specified directory does not exist.");
            return;
        }
        if (!directory.isDirectory()) {
            System.out.println("The specified file is not a directory.");
            return;
        }

        /* Listen for connection requests from clients.  For
         each connection, create a separate Thread of type
         ConnectionHandler to process it.  The ConnectionHandler
         class is defined below.  The server runs until the
         program is terminated, for example by a CONTROL-C. */

        try {
            listener = new ServerSocket(LISTENING_PORT);
            System.out.println("Listening on port " + LISTENING_PORT);
            while (true) {
                connection = listener.accept();
                new ConnectionHandler(directory, connection);
            }
        } catch (Exception e) {
            System.out.println("Server shut down unexpectedly.");
            System.out.println("Error:  " + e);
            return;
        }

    } // end main()

    static class ConnectionHandler extends Thread {
        // An object of this class is a thread that will
        // process the connection with one client.  The
        // thread starts itself in the constructor.

        File directory; // The directory from which files are served

        Socket connection; // A connection to the client.

        TextReader incoming; // For reading data from the client.

        PrintWriter outgoing; // For transmitting data to the client.

        ConnectionHandler(File dir, Socket conn) {
            // Constructor.  Record the connection and
            // the directory and start the thread running.
            directory = dir;
            connection = conn;
            start();
        }

        void sendList() throws Exception {
            // This is called by the run() method in response
            // to an "index" command.  Send the list of files
            // in the directory.
            String[] fileList = directory.list();
            for (int i = 0; i < fileList.length; i++)
                outgoing.println(fileList[i]);
            outgoing.flush();
            outgoing.close();
            if (outgoing.checkError())
                throw new Exception("Error while transmitting data.");
        }

        private void sendSize(String fileName) {
            File f = new File(fileName);
            if ((!f.exists()) || f.isDirectory()) {
                outgoing.println("error");
            } else {
                outgoing.println("ok");
                long length = f.length();
                outgoing.println(length);
            }
            // Get the number of bytes in the file
        }

        private void ChangeDir(String fileName) throws Exception {
            File file = new File(directory, fileName);
            if ((!file.exists()) || file.isDirectory()) {
                outgoing.println("error");
            } else {
                directory = file;
                outgoing.println("ok");

            }
            if (outgoing.checkError())
                throw new Exception("Error while trying to change directory.");
        }

        private void ReceiveFile(String fileName) throws Exception {
            File file = new File(fileName);
            BufferedReader in = null;
            if ((file.exists())) {
                outgoing.println("error: file already exists");
            } else {
                outgoing.println("ok");
                TextReader fileIn = new TextReader(new FileReader(fileName));
                while (fileIn.peek() != '\0') {
                    // Read and send lines from the file until
                    // an end-of-file is encountered.
                    in = new BufferedReader(new InputStreamReader(connection
                            .getInputStream()));
                }
            }
            if (outgoing.checkError())
                throw new Exception("Error while Receiving data.");
        }

        void sendFile(String fileName) throws Exception {
            // This is called by the run() command in response
            // to "get <fileName>" command.  If the file doesn't
            // exist, send the message "error".  Otherwise,
            // send the message "ok" followed by the contents
            // of the file.
            File file = new File(directory, fileName);
            if ((!file.exists()) || file.isDirectory()) {
                // (Note:  Don't try to send a directory, which
                // shouldn't be there anyway.)
                outgoing.println("error");
            } else {
                outgoing.println("ok");
                TextReader fileIn = new TextReader(new FileReader(file));
                while (fileIn.peek() != '\0') {
                    // Read and send lines from the file until
                    // an end-of-file is encountered.
                    String line = fileIn.getln();
                    outgoing.println(line);
                }
            }
            outgoing.flush();
            outgoing.close();
            if (outgoing.checkError())
                throw new Exception("Error while transmitting data.");
        }

        public void run() {
            // This is the method that is executed by the thread.
            // It creates streams for communicating with the client,
            // reads a command from the client, and carries out that
            // command.  The connection is logged to standard output.
            // An output beginning with ERROR indicates that a network
            // error occurred.  A line beginning with OK means that
            // there was no network error, but does not imply that the
            // command from the client was a legal command.
            String command = "Command not read";
            try {
                incoming = new TextReader(connection.getInputStream());
                outgoing = new PrintWriter(connection.getOutputStream());
                command = incoming.getln();
                if (command.equals("list")) {
                    sendList();
                } else if (command.startsWith("get")) {
                    String fileName = command.substring(3).trim();
                    sendFile(fileName);
                } else if (command.startsWith("size")) {
                    String fileName = command.substring(4).trim();
                    sendSize(fileName);
                } else if (command.startsWith("put")) {
                    String fileName = command.substring(3).trim();
                    ReceiveFile(fileName);
                } else if (command.startsWith("cd")) {
                    String fileName = command.substring(2).trim();
                    ChangeDir(fileName);
                } else if (command.startsWith("exit")) {
                    outgoing.flush();
                    connection.close();
                } else {
                    outgoing.println("unknown command");
                    outgoing.flush();
                }
                System.out.println("OK    " + connection.getInetAddress() + " "
                        + command);
            } catch (Exception e) {
                System.out.println("ERROR " + connection.getInetAddress() + " "
                        + command + " " + e);
            } finally {
                try {
                    connection.close();
                } catch (IOException e) {
                }
            }
        }
            public static void main(String[] args) throws IOException
            {
                int PORT = 8134;
                InputStream inStream;
                DataInputStream inDataStream;
                OutputStream outStream;
                DataOutputStream outDataStream;
                String message="";
                String received="";
         
                System.out.println("Server Started");
         
                ServerSocket sock = new ServerSocket(PORT);
                Socket conn = sock.accept();    
                do{
                inStream = conn.getInputStream ();
                inDataStream = new DataInputStream ( inStream );
                message = inDataStream.readUTF();        
                System.out.println("Client sent: "+message);
         
                DataInputStream dis = new DataInputStream(System.in);
                message = dis.readLine();
                outStream = conn.getOutputStream();
                outDataStream = new DataOutputStream (outStream);    
                outDataStream.writeUTF(message);    
                }while(!message.equals("bye"));
                conn.close();
            }
        }
        
        
    } // end nested class ConnectionHandler
 //end class FileServer

This is the Client Class:

import java.io.*; // Import some needed classes
import java.net.*;
import java.util.*;
import sun.net.*;

public class Client 
{        
    public static void main(String args[]) throws IOException
    {
        int PORT = 8134;
        InputStream inStream;
        DataInputStream inDataStream;
        OutputStream outStream;
        DataOutputStream outDataStream;
        String message = "";
            
        InetAddress host = InetAddress.getLocalHost();
        String diffHost = args[0];
        Socket sock = new Socket(diffHost,PORT);
        System.out.println("Client Started");
        do{
            System.out.println("Enter your command here: ");
            DataInputStream dis = new DataInputStream(System.in);
            message = dis.readLine();
            outStream = sock.getOutputStream();
            outDataStream = new DataOutputStream (outStream);        
            outDataStream.writeUTF(message);    
 
            inStream = sock.getInputStream ();
            inDataStream = new DataInputStream ( inStream );
            message = inDataStream.readUTF();
            System.out.println("Server Sent: "+message);
        }while(!message.equals("bye"));
    }
}

this is the textreader class

/*   
This file defines the Class TextReader as a subclass of FilterReader..
The TextReader provides methods for reading data expressed in human-readable
ASCII text format.

This file also defines three public subclasses of RuntimeException to represent
errors that can occur during input.  These classes are static nested inside the
TextReader class.

This is a modest variation on an earlier class called AsciiInputStream, which served
a similar function for Java 1.0, where InputStreams are used instead of Readers
for character input.

David Eck
August 18, 1998

*/


import java.io.*;


public class TextReader extends FilterReader {

// ************************** Exception Classes *******************************

    // First, define the exceptions that can be thrown by this class.  These exceptions
    // are subclasses of RuntimeException, so they do not require mandatory error-handling.
    // Also, if you prefer, you can turn off excpetions by calling the IOCheck() method.
    // In that case, when an exception occurs during processing by one of the methods
    // of the TextReader class, an errorFlag is set but no exception is thrown.
    // If you use this alternative error-handling strategy, then you should call the
    // checkError() method after each input operation to see whether the operation
    // completed successfully.

    public static class Error extends RuntimeException {
          // Represents any excpetion that occurs in the TextReader Class.
          // In fact, only general IOExceptions are translated directly into
          // TextReader.Error.  Other exceptions throw objects belonging
          // to one of the following subclasses of TextReader.Error.
       Error(String errorMessage) {
          super(errorMessage);
       }
    }

    public static class FormatError extends Error {
          // Illegal data: an illegal number or an illegal boolean value
       FormatError(String errorMessage) {
          super(errorMessage);
       }
    }

    public static class EOFError extends Error {
         // attempt to read past end of stream
       EOFError(String errorMessage) {
          super(errorMessage);
       }
    }


// ***************************** Constructors ********************************

public TextReader(BufferedReader s) {
  super(s);
}

public TextReader(Reader s) {
  super(new BufferedReader(s));
}

public TextReader(InputStream s) {
  super( new BufferedReader(new InputStreamReader(s)) );
}

// ***************************** Error Checking *****************************

public void IOCheck(boolean throwExceptions) {  // call IOCheck(false) to turn
  throwExceptionOnError = throwExceptions;     //   off exceptions, then check
}                                               //   for errors by calling checkError()

public boolean error() {   // returns true if the most recent input operation on
  return errorFlag;       // this TextReader produced an error.  An error
}                          // message can be retrieved by calling getErrorMessage()

public String getErrorMessage() {            // if the most recent operation on
  return errorFlag ? errorMessage : null;   // this TextReader produced an error, this
}                                            // gets an error message for that error

// *************************** Input Methods ********************************

  // peek()  -- returns the next character about to be read from the stream,
  //     without removing it from the stream.  '\n' is returned if the next
  //     thing in the stream is end-of-line.  '\0' is returned if the next
  //     thing is end-of-file.  (There is no way for peek() to distinguish
  //     between EOF and a null character in the input data.  Use eof() to
  //     test for end-of-file.)
  
  // getAnyChar() -- reads and returns the next character in the stream, even if it
  //     is a whitespace character.  It is an error to read past end-of-file.
  //     (Note that getChar() skips over whitespace characters before reading.)
  
  // getChar(), getByte(), etc. -- skip over whitespace characters, then try to read a
  //     value of the specified type.  An error can occur if the right type of data
  //     is not found.  A "word" is any sequence of non-whitespace characters.
  //     A "boolean" is one of the words (ignoring case) "true", "false", "yes", "no"
  //     "t", "f", "y", "n", "0", "1".  An "Alpha" is a sequence of letters.  getAlpha()
  //     is a special case in that it will skip over all non-letters before reading,
  //     rather than just skipping whitespace characters.
  
  // getln() -- reads all characters up to the next end-of-line and returns them
  //     as a String.  The end-of-line is then read and discarded.
  
  // getlnChar(), getlnByte() etc. -- Work the same as getChar(), etc., except that
  //     after the value is read, any other characters on the same line, including the
  //     end-of-line, are read and discarded.
  
  // eoln() -- this first reads and discards any spaces and tabs.  Then tests whether
  //     the next thing in the stream is an end-of-line.  The end-of-file also counts
  //     as an end of line.  If you want to test for eoln without discarding spaces
  //     and tabs, check whether peek() == '\n' or '\0'.

  // eof() -- this first reads and discards any spaces, ends-of-line and tabs.  Then tests
  //     whether the next thing in the stream is the end-of-file.  If you want to test for
  //     eof without discarding spaces, ends-of-line, and tabs, check whether peek() == '\0'.
  
  // skipWhiteSpace() -- reads and discards any whitespace characters (spaces, tabs, and
  //     end-of-lines).  Stops when the next character is a non-whitespace character or is eof.
  
  // skipNonLetters() -- reads and discards any non-letters, stopping when the next character
  //     is a letter or the end-of-file.

public char peek()          { errorFlag = false; return lookChar(); }

public char getAnyChar()    { errorFlag = false; return readChar(); }

public char getChar()       { errorFlag = false; skipWhiteSpace(); return readChar(); }
public byte getByte()       { errorFlag = false; return (byte)readInteger(-128L,127L); }
public short getShort()     { errorFlag = false; return (short)readInteger(-32768L,32767L); }   
public int getInt()         { errorFlag = false; return (int)readInteger((long)Integer.MIN_VALUE, (long)Integer.MAX_VALUE); }
public long getLong()       { errorFlag = false; return readInteger(Long.MIN_VALUE, Long.MAX_VALUE); }
public float getFloat()     { errorFlag = false; return readFloat(); }
public double getDouble()   { errorFlag = false; return readDouble(); }
public boolean getBoolean() { errorFlag = false; return readBoolean(); }
public String getWord()     { errorFlag = false; return readWord(); }
public String getAlpha()    { errorFlag = false; return readAlpha(); }

public String getln()         { errorFlag = false; return readLine(); }

public char getlnChar()       { char x=getChar();       dropLine();  return x; }
public byte getlnByte()       { byte x=getByte();       dropLine();  return x; }
public short getlnShort()     { short x=getShort();     dropLine();  return x; }
public int getlnInt()         { int x=getInt();         dropLine();  return x; }
public long getlnLong()       { long x=getLong();       dropLine();  return x; }
public float getlnFloat()     { float x=getFloat();     dropLine();  return x; }
public double getlnDouble()   { double x=getDouble();   dropLine();  return x; }
public boolean getlnBoolean() { boolean x=getBoolean(); dropLine();  return x; }
public String getlnWord()     { String x=getWord();     dropLine();  return x; }
public String getlnAlpha()    { String x=getAlpha();    dropLine();  return x; }

public boolean eoln() {
  char ch = lookChar();
  while (!EOF && !errorFlag && (ch == ' ' || ch == '\t')) {
     readChar();
     ch = lookChar();
  }
  return (ch == '\n' || EOF);
}

public boolean eof() {
  char ch = lookChar();
  while (!EOF && !errorFlag && (ch == ' ' || ch == '\n' || ch == '\t')) {
     readChar();
     ch = lookChar();
  }
  return EOF;
}

public void skipWhiteSpace() {
  char ch = lookChar();
  while (!errorFlag && (ch == ' ' || ch == '\n' || ch == '\t')) {
     readChar();
     ch = lookChar();
  }
}

public void skipNonLetters() {
  char ch = lookChar();
  while (!errorFlag && !EOF && !Character.isLetter(ch)) {
     readChar();
     ch = lookChar();
  }
}

public void close() {
  errorFlag = false;
  try {
     in.close();
  }
  catch (IOException e) {
     errorFlag = true;
     errorMessage = e.toString();
  }
}

//*************************** private implementation stuff ***********************

private int lookAhead = -1;          // one-character buffer; -1 indicates the buffer is empty
private boolean errorFlag = false;    // set to true if most recent operation produced an error
private String errorMessage = "";     // error message for the most recent error
private boolean EOF = false;          // has the end-of-stream been encountered?
private boolean throwExceptionOnError = true;  // determines which type of error-handling is used

// Three utility routines for throwing exceptions.

private void doError(String message) {
  errorFlag = true;
  errorMessage = message;
  if (throwExceptionOnError)
     throw new Error(message);
}

private void doFormatError(String message) {
  errorFlag = true;
  errorMessage = message;
  if (throwExceptionOnError)
     throw new FormatError(message);
}

private void doEOFError(String message) {
  errorFlag = true;
  errorMessage = message;
  if (throwExceptionOnError)
     throw new FormatError(message);
}

// The remaining methods are basic methods for reading the various types of
// data from the stream

private char readChar() {
  char ch = lookChar();
  if (EOF)
     doEOFError("Attempt to read past end-of-data in input stream.");
  lookAhead = -1;
  return ch;
}

private boolean possibleLineFeedPending = false;  // for dealing with \r\n pairs

private char lookChar() {
  if (lookAhead != -1) {
     if (lookAhead == '\r')
        return '\n';
     else
       return (char)lookAhead;
  }
  if (EOF)
     return '\0';
  try {
     int n = in.read();
     if (n == '\n' && possibleLineFeedPending) {  // ignore \n of \r\n pair
        n = in.read();
     }
     possibleLineFeedPending = (n == '\r');
     lookAhead = n;
     if (lookAhead == -1) {
        EOF = true;
        return '\0';
     }
  }
  catch (IOException e) {
     doError(e.getMessage());
  }
  if (lookAhead == '\r')  // represent all eoln's with \n
     lookAhead = '\n';
  return (char)lookAhead;
}

private void dropLine() {
  while (!errorFlag) {
     if (lookChar() == '\0')
        return;
     if (readChar() == '\n')
        return;
  }
}

private String readLine() {
  StringBuffer s = new StringBuffer(100);
  char ch = readChar();
  while (!errorFlag && ch != '\n') {
     s.append(ch);
     ch = lookChar();
     if (ch == '\0')
        break;
     ch = readChar();
  }
  return s.toString();
}

private String readWord() {
  skipWhiteSpace();
  if (errorFlag)
     return null;
  StringBuffer s = new StringBuffer(50);
  char ch = lookChar();
  if (EOF) {
     doEOFError("Attempt to read past end-of-data");
     return null;
  }
  while (!errorFlag && !EOF && ch != '\n' && ch != ' ' && ch != '\t') {
     s.append(readChar());
     ch = lookChar();
  }
  return s.toString();
}


private String readAlpha() {
  skipNonLetters();
  if (errorFlag)
     return null;
  StringBuffer s = new StringBuffer(50);
  char ch = lookChar();
  if (EOF) {
     doEOFError("Attempt to read past end-of-data");
     return null;
  }
  while (!errorFlag && Character.isLetter(ch)) {
     s.append(readChar());
     ch = lookChar();
  }
  return s.toString();
}


public float readFloat() {
  double d = readDouble();
  if (errorFlag)
     return Float.NaN;
  if (Math.abs(d) > Float.MAX_VALUE)
     doFormatError("Input number outside of legal range for values of type float");
  return (float)d;
}

public double readDouble() {
  double x = Double.NaN;
  StringBuffer s=new StringBuffer(50);
  skipWhiteSpace();
  char ch = lookChar();
  if (ch == '-' || ch == '+') {
      s.append(readChar());
      skipWhiteSpace();
      ch = lookChar();
  }
  if ( (ch < '0' || ch > '9') && (ch != '.') ) {
     if (EOF)
        doEOFError("Expecting a floating-point number and found end-of-data");
     else
        doFormatError("Expecting a floating-point number and found \""  + ch + "\"" );
     return Double.NaN;
  }
  boolean digits = false;
  while (ch >= '0' && ch <= '9') {
      s.append(readChar());
      ch = lookChar();
      digits = true;
  }
  if (ch == '.') {
     s.append(readChar());
     ch = lookChar();
     while (ch >= '0' && ch <= '9') {
         s.append(readChar());
         ch = lookChar();
         digits = true;
     }
  }
  if (!digits) {
     doFormatError("No digits found in floating-point input.");
     return Double.NaN;
  }
  if (ch == 'E' || ch == 'e') {
     s.append(readChar());
     ch = lookChar();
     if (ch == '-' || ch == '+') {
         s.append(readChar());
         ch = lookChar();
     }
     if ( (ch < '0' || ch > '9') && (ch != '.') ) {
        if (EOF)
           doEOFError("Expecting exponent for a floating-point number and found end-of-data");
        else
           doFormatError("Expecting exponent for a floating-point number and found \""  + ch + "\"");
        return Double.NaN;
     }
     while (ch >= '0' && ch <= '9') {
         s.append(readChar());
         ch = lookChar();
     }
  }
  String str = s.toString();
  Double d;
  try {
     d = new Double(str);
     x = d.doubleValue();
  }
  catch (NumberFormatException e) {
     x = Double.NaN;
  }
  if (Double.isNaN(x) || Double.isInfinite(x)) {
     doFormatError("Illegal floating point number");
     return Double.NaN;
  }      
  return x;
}

public boolean readBoolean() {
  boolean ans = false;
  String s = getWord();
  if (errorFlag)
     return false;
  if ( s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t") ||
             s.equalsIgnoreCase("yes")  || s.equalsIgnoreCase("y") ||
             s.equals("1") ) {
       ans = true;
   }
   else if ( s.equalsIgnoreCase("false") || s.equalsIgnoreCase("f") ||
             s.equalsIgnoreCase("no")  || s.equalsIgnoreCase("n") ||
             s.equals("0") ) {
       ans = false;
   }
   else
      doFormatError("Illegal input for value of type boolean: \"" + s + "\"");
   return ans;
}


private long readInteger(long min, long max) {  // read long integer, limited to specified range
  skipWhiteSpace();
  if (errorFlag)
     return 0;
  char sign = '+';
  if (lookChar() == '-' || lookChar() == '+') {
     sign = getChar();
     skipWhiteSpace();
  }
  long n = 0;
  char ch = lookChar();
  if (ch < '0' || ch > '9') {
     if (EOF)
        doEOFError("Expecting an integer and found end-of-data");
     else
        doFormatError("Expecting an integer and found \""  + ch + "\"");
     return 0;
  }
  while (!errorFlag && ch >= '0' && ch <= '9') {
     readChar();
     n = 10*n + (int)ch - (int)'0';
     if (n < 0) {
        doFormatError("Integer value outside of legal range");
        return 0;
     }
     ch = lookChar();
  }
  if (sign == '-')
     n = -n;
  if (n < min || n > max) {
     doFormatError("Integer value outside of legal range");
     return 0;
  }
  return n;
}

// Override the read() methods from FilterReader so that they will work if a
// TextReader is wrapped inside another file.  (This is necessary to take
// lookAhead into account.)

public int read() throws IOException {
  if (lookAhead == -1)
     return super.read();
  else {
     int x = lookAhead;
     lookAhead = -1;
     return x;
  }
}

public int read(char[] buffer, int offset, int count) throws IOException {
  if (lookAhead == -1 || count <= 0)
     return super.read(buffer,offset,count);
  else if (count == 1) {
     buffer[offset] = (char)lookAhead;
     lookAhead = -1;
     return 1;
  }
  else {
     buffer[offset] = (char)lookAhead;
     lookAhead = -1;
     int ct = super.read(buffer,offset+1,count-1);
     return ct + 1;
  }
}

} // end of class TextReader

So what is your soecific problem? What error are you getting? What effect are you observing that you did not expect?

I am not sure if my Client/Server is working correctly. I am trying to get them to where they will do what the specs ask. I am not sure if I am even approaching it correctly because I have no experience in this area and was wondering if someone could let me know if it was close to being right or not and what I needed to change.

1) I am unsure about the command line arguments and how to use them to look for server and port #.

2) Once #1 works, then I can make sure the client and server connect- right now I am having a hard time figuring out how to make them connect correctly.

3) Don't know if I am getting the upload/download sections working correctly.

4) Not sure how to change directories in java.

5) I am going to I'm also going to list errors below:

The client gives me this error:
java.lang.ArrayIndexOutOfBoundsException: 0
at Client.main(Client.java:29)
Exception in thread "main"

The server gives me this error, but only if I have it used more than once:
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:331)
at java.net.ServerSocket.bind(ServerSocket.java:318)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:97)
at FileServer$ConnectionHandler.main(FileServer.java:240)
Exception in thread "main"

This article has been dead for over six months. Start a new discussion instead.