You are on page 1of 4

Department of Computer Science & Engineering

Course Title: Parallel Processing and Distributed System Lab


Course Code: CSE 434

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 basic Server and
Client application.
Theory: The implementation of a basic client-server
application involves creating two separate programs - a client
program and a server program - that communicate with each
other over a network connection. Here are the steps to
implement a basic client-server application:
Create the server program: Write the server program that
listens for incoming client requests and responds
appropriately. The server program should create a socket, bind
it to a specific IP address and port, and then listen for
incoming client connections. When a client connection is
accepted, the server program should read and process the
client request, and send back a response.
Create the client program: Write the client program that sends
requests to the server and receives responses. The client
program should create a socket, connect it to the server's IP
address and port, and then send a request message to the
server. The client program should then read the server's
response and process it accordingly.
Requirement:
1.Java Development Kit (JDK)
2.Notepad

Implementation Code:

For Server:
import java.io.*;
import java.net.*;
public class Server
{
public static void main(String args[])
{
try{
ServerSocket ss = new ServerSocket(6666);
Socket s = ss.accept();
DataInputStream dis = new
DataInputStream(s.getInputStream());
String str = (String)dis.readUTF();
System.out.println(str);
ss.close();
}

catch( Exception e)
{
System.out.println(e);}
}
}

For Client:
import java.io.*;
import java.net.*;
public class Client
{
public static void main(String args[])
{
try{

Socket s = new Socket("localhost",6666);


DataOutputStream dout = new
DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello");
dout.flush();
dout.close();
s.close();
}
catch( Exception e)
{
System.out.println(e);}

Experimental Output:

You might also like