Professional Documents
Culture Documents
Lab02 (191311129)
Lab02 (191311129)
Lab Report
Submitted by Submitted to
Name: Md. Sabbir Hossain Mohammad Kasedullah
ID: 191311129 Lecturer, Dept. CSE, VU
Section: A (12th Tokey Ahmed
Semester) Lecturer, Dept. CSE, VU
Batch: 20th Batch
Signature
Date of Issue: 11th April 2023 Date of Submission: 25th April 2023
Question 1:Implementation of both way
commuinication Server and Client application.
Theory: The implementation of a two-way communication server
and client application typically involves the following steps:
Set up the server: The next step is to set up the server that
will handle incoming connections from clients. This typically
involves creating a listening socket that is bound to a
specific port on the server machine, and then waiting for
incoming connections.
Accept client connections: Once the server is set up, it can
start accepting incoming connections from clients. When a
client connects to the server, the server should create a new
thread or process to handle that connection, so that it can
continue to accept new connections.
Requirement:
1.Java Development Kit (JDK)
2.Notepad
Implementation Code:
For Server:
import java.net.*;
import java.io.*;
String str="",str2="";
while(!str.equals("stop"))
{
str=din.readUTF();
System.out.println("Client: " +str);
str2 = br.readLine();
dout.writeUTF(str2);
dout.flush();
din.close();
dout.close();
s.close();
ss.close();
}
}
For Client:
import java.net.*;
import java.io.*;
String str="",str2="";
while(!str.equals("stop"))
{
str=br.readLine();
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println("Server: " +str2);
}
din.close();
s.close();
}
}
}
Experimental Output: