PROGRAM
import java.io.*;
import java.net.*;
class tcpser
{
public static void main(String arg[])
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ServerSocket ob=new ServerSocket(95);
Socket obj=ob.accept();
OutputStream op=obj.getOutputStream();
System.out.println("Enter a string (x to exit)");
String str;
do
{
str=br.readLine();
op.write(str.getBytes());
}while(!str.equals("x"));
op.close();
obj.close();
}
catch(Exception ex)
{
}
}
}
import java.io.*;
import java.net.*;
class tcpcl
{
public static void main(String arg[])
{
try
{
Socket ob=new Socket("localhost",95);
InputStream ip=ob.getInputStream();
String t;
do
{
byte b[]=new byte[ip.available()];
ip.read(b);
t=new String(b);
System.out.println(t);
}while(!t.equals("x"));
ip.close();
ob.close();
}
catch(Exception ex)
{
}
}
}
OUTPUT
Enter a string (x to exit)
Are U there?
Hai..Listen to me
x
Are U there?
Hai..Listen to me
x
SanDisk 32GB Class 10 microSDXC Memory Card with Adapter (SDSQUAR-032G-GN6MA)
(as of 11/01/2018 5:00 pm - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.'>)NETWORK COMMUNICATION USING TCP/IP is a post from ShoutToWorld - Let's Learn Let's Shout - Helping bloggers and developers.