Experiment No.-9
Experiment No.-9
Experiment No.-9
Experiment No.-9
Aim - Implementation of stop and wait protocol in any language like C++ , Java or Python.
Code-
Server:
import java.io.*;
import java.net.*;
Client:
import java.io.*;
import java.net.*;
String message;
do {
System.out.print("Client: ");
message = userInput.readLine();
out.println(message);
String response = in.readLine();
System.out.println("Server: " + response);
} while (!message.equals("bye"));
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Output-
Server
Client
Experiment No.-10
Aim - Write a program in java to find the IP address of the system.
Code -
import java.net.InetAddress;
import java.net.UnknownHostException;
Output-
Experiment No.-11
Aim - Write a program in java to find the IP address of the any site if name is given.
Code –
import java.net.InetAddress;
import java.net.UnknownHostException;
try {
InetAddress ipAddress = InetAddress.getByName(domainName);
System.out.println("IP Address of " + domainName + " is: " +
ipAddress.getHostAddress());
} catch (UnknownHostException e) {
System.out.println("Unable to find IP address for " + domainName);
e.printStackTrace();
}
}
}
Output-