TCP-CLIENT
import java.net.*;
import java.util.*;
import java.io.*;
class client
{
public static void main(String args[]) throws IOException,Exception
{
Socket s=new Socket(InetAddress.getLocalHost(),9000);
InputStream in=s.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(in));
String x=null;
while((x=br.readLine())!=null)
{
System.out.println(" "+x);
}
}
}
TCP-SERVER
import java.net.*;
import java.io.*;
import java.util.*;
class server1
{
public static void main(String args[]) throws IOException,Exception
{
ServerSocket ss=new ServerSocket(9000);
while(true)
{
Socket client=ss.accept();
OutputStream out=client.getOutputStream();
PrintWriter pw=new PrintWriter(out,true);
String x="welcome to kavery";
pw.println(x);
No comments:
Post a Comment