@Override
	public List<Node> neighbors(Node node) throws IOException {
//		System.out.println("Calling neighbors.");
		LinkedList<Node> list = null;
		String input = null;
		try {
			
			StringBuilder sb = new StringBuilder("neighbors\n");
			sb.append(ProtocolParser.encodeEmptyNode(node));
			String output = ProtocolParser.appendLineCount(sb.toString());
			writer.print(output);
			writer.flush();
			
			int lines = Integer.parseInt(reader.readLine().trim());
			sb = new StringBuilder();
			for (int i = 0; i < lines; i++) {
				String line = reader.readLine().trim();
				if (line.equals("List")) {
					node = ProtocolParser.decodeNode(sb.toString(), node);
					sb = new StringBuilder("List\n");
				} else {
					sb.append(line);
					sb.append("\n");
				}
			}
			
			input = sb.toString();
			
		} catch (IOException e){
			System.err.println("ERROR: problem interacting with server.");
			System.err.println(e.getMessage());
		} catch (NullPointerException e) {
			System.err.println("ERROR: not receiving server response.");
		}
		
		if (input != null)
			if (input.startsWith("List")) {
				List<Object> rawList = ProtocolParser.decodeList(input);
				list = new LinkedList<Node>();
				for (Object o : rawList) {
					if (o instanceof Node) {
						list.add((Node) o);
					} else {
						System.err.println("ERROR: Should be getting a list of nodes from Client.neighbors, but not.");
					}
				}
				
			} else if (input.startsWith("IOException")) {
				throw ProtocolParser.decodeIOException(input);
			}
		
		return list;
	}