Computer Network Notes
Computer Network Notes
Computer Network Notes
Aim- Implementation of stop and wait protocol in any language like C++ , Java or Python.
Code- Server
import java.io.*;
import java.net.*;
main(String[] args) {
try {
System.out.println("Connection established.");
String message;
do { message =
in.readLine();
out.println("ACK");
} while (!message.equals("bye"));
socket.close();
serverSocket.close(); } catch
(IOException e) {
e.printStackTrace();
java.io.*; import
java.net.*;
main(String[] args) {
try {
String message;
do {
System.out.print("Client: ");
message = userInput.readLine();
out.println(message);
} while (!message.equals("bye"));
socket.close(); }
catch (IOException e) {
e.printStackTrace();
Server
Client
java.net.UnknownHostException;
Code-
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();
}
}
}