I need help completing this java program for an Ubuntu Server project. Note the
ID: 3649730 • Letter: I
Question
I need help completing this java program for an Ubuntu Server project.Note the locations that state **** fill out this part****
// Client side
import java.io*;
import java.net.*;
public class Client {
public static void main(String args[])
{
String hostname = "";
String message = "";
String dnsserver_name = "10.0.7.218";
int dnsserver_port = 2020;
int server_port = 2010;
//create a buffered reader for reading the keyboard
BuffferedReader in = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.print("Enter computer id:"));
hostname = in.readLine();
System.out.print("Enter messate to send");
message = in,readLine();
messate += " ";
System.out.pringln (Message);
}catch (IOException e) {}
try{
//create a socket for the name service server
// *****fill out this part
//send a name resolve request
//*****fill out this part
//read a name to resolve request
//*****fill out this part
String resolveddname = br.readLine();
System.out.println("resolved name: " + resolvedname);
//connect to the host
Socket s = new Socket(resolvedname, server_port);
//send a message to the host
(new DataOutputStream (s.getOutputStream())).writeBytes(message);
} catch (IOExcpetion e){};
}
}
// server side
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
public class dnsserver
{
public static void main(String args[])
{
int dnsserver_port = 2020;
while(true){
try{
//creating a socket and accept the dnsserver_port
// *****fill out this part*****
// create a buffered reader to read the socket input
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream());
// read a line from a socket buffered reader
String hosename = br.readLine();
// print out some infotmation on dns servers screen
System.out.println("Resolving Host Name " + hostname);
//provide an IP Address to the client
//*****fill out this part*****
} catch (IOException e){};
}
}
}
Explanation / Answer
// Client side import java.io*; import java.net.*; public class Client { public static void main(String args[]) { String hostname = ""; String message = ""; String dnsserver_name = "10.0.7.218"; int dnsserver_port = 2020; int server_port = 2010; //create a buffered reader for reading the keyboard BuffferedReader in = new BufferedReader(new InputStreamReader(System.in)); try{ System.out.print("Enter computer id:")); hostname = in.readLine(); System.out.print("Enter messate to send"); message = in,readLine(); messate += " "; System.out.pringln (Message); }catch (IOException e) {} try{ //create a socket for the name service server // *****fill out this part //send a name resolve request //*****fill out this part //read a name to resolve request //*****fill out this part String resolveddname = br.readLine(); System.out.println("resolved name: " + resolvedname); //connect to the host Socket s = new Socket(resolvedname, server_port); //send a message to the host (new DataOutputStream (s.getOutputStream())).writeBytes(message); } catch (IOExcpetion e){}; } } // server side import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.*; public class dnsserver { public static void main(String args[]) { int dnsserver_port = 2020; while(true){ try{ //creating a socket and accept the dnsserver_port // *****fill out this part***** // create a buffered reader to read the socket input BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()); // read a line from a socket buffered reader String hosename = br.readLine(); // print out some infotmation on dns servers screen System.out.println("Resolving Host Name "
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.