0% found this document useful (0 votes)
17 views

Assignment 9 GRP-B (Hello)

Uploaded by

defana4720
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Assignment 9 GRP-B (Hello)

Uploaded by

defana4720
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.io.

*;
import java.net.*;

public class ClientCode


{
Socket socket;
BufferedReader sock_in,kdb_in;
PrintWriter sock_out;
String str;
public ClientCode()
{
try{

Socket socket=new Socket("127.0.0.1",8080);


kdb_in=new BufferedReader(new InputStreamReader(System.in));
sock_in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
sock_out=new PrintWriter(socket.getOutputStream());
while(true)
{

System.out.println("Enter the msg");


str=kdb_in.readLine();
sock_out.println(str);
sock_out.flush();
System.out.println("Msg from Server");
str=sock_in.readLine();
System.out.println(str);
if(str.equals("bye"))
break;
}
//socket.close();
}catch (Exception e) { }
}
public static void main(String arg[])
{
new ClientCode();
}
}

/* OUTPUT

Enter the msg


hiiii
Msg from Server
hii,welcome to svit
Enter the msg
what r u doing?
Msg from Server
nothing
Enter the msg
ok bye
Msg from Server
bye

You might also like