@Override
    public void run() {
        BufferedReader in = null;

        try {
            // set timeout to 10 seconds so the clients don't block the server for ever
            connect.setSoTimeout(10000);
            //get character input stream from client
            in = new BufferedReader(new InputStreamReader(connect.getInputStream()));

            //get first line of request from client
            String input = in.readLine();
            if (input == null || !input.equals("Type:DV")) throw new Exception("Invalid request");
            input = in.readLine(); // get next line: Len:#
            //create StringTokenizer to parse request
            StringTokenizer parse = new StringTokenizer(input, ":");
            parse.nextToken(); // ignore Len
            //parse out length
            int len = Integer.parseInt(parse.nextToken());
            if (verbose) {
                System.out.println("Expecting " + len + " targets");
            }
            for (int i = 1; i <= len; i++) {
                //get first line of request from client
                input = in.readLine();
                if (input == null) throw new Exception("Invalid request");
                parse = new StringTokenizer(input, ":");
                String ip = parse.nextToken();
                int dv = Integer.parseInt(parse.nextToken());
                Target t = new Target(ip, dv);
                if (verbose) {
                    System.out.println("Received target #" + i + ": " + t);
                }
            }
        } catch (SocketTimeoutException ste) {
            System.out.println("Connection timeout");
        } catch (Exception ioe) {
            System.err.println("Server Error: " + ioe);
        } finally {
            close(in); //close character input stream
            close(connect); //close socket connection

            if (verbose) {
                System.out.println("Connection closed.\n");
            }
        }
    }