I have a Server / Client relationship that I've built. I have a problem with the client. The server works great. Simple DNS lookup. I have it set so I can telnet into it and it connects fine and immediately returns "Connected to" + serverName. Typically localhost. That's the first line. The second line is "Escape character is '^]'". The server then waits for the ipName such as "www.java-forums.org" then does the lookup returns the IP address and then disconnects the client.

The part I'm having problems with is the client. The usage of the client is
Java Code:
$java DNSClient 127.0.0.1 www.java-forums.org
where the first argument is the server to connect to and the second argument is the address to lookup.

Java Code:
import java.net.*;
import java.io.*;

public class DNSClient
{
	// the default port
	public static final int PORT = 6052;
	// this could be replaced with an IP address or IP name
	public static final String host = "localhost";
	
	public static void main(String[] args) throws java.io.IOException {
		if (args.length == 0)
			System.out.println("No Server Connection. Please provide Server Name.");
		else if (args.length == 1){
			System.out.println("IP Name has not been specified.");
			System.out.println("Please input address like 'www.google.com'");
		}
		else if (args.length == 2){
			Socket clientConn = null;
			BufferedReader fromServer = null;
			DataOutputStream toServer = null;
			// 1. read the IPName from args array
			String serverName = args[0];
			String ipName = args[1];
			String ipAddy;
						
			try {
				// 2. open a socket connection to default port
				clientConn = new Socket(serverName, PORT);
				// 3. Write the ipName to the socket
				toServer = new DataOutputStream(clientConn.getOutputStream());
				toServer.write(ipName.getBytes());
				// 4. read IP address from the socket
				fromServer = new BufferedReader(new InputStreamReader(clientConn.getInputStream()));
				ipAddy = fromServer.readLine();
				// 5. display the IP address
				System.out.println(ipAddy);
				
				

			} catch (java.io.IOException ioe) {
				System.err.println(ioe);
			}
			finally {
				// let's close streams and sockets
				if (clientConn != null)	clientConn.close();
			}
		  }
		  else System.out.println("You have specified too many arguments.");
	}
}

So my output obviously returns the first line which is connected to localhost instead of returning the IP Address of the 2nd parameter being sent.

Am I not using DataOutputStream to send the 2nd argument correctly or should is there a way to ignore the first two lines returned from the server? and then pass the address so it can be returned to the command line?

thank you,

-blaqkout